forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests_hedgedoc.py
More file actions
45 lines (40 loc) · 1.64 KB
/
tests_hedgedoc.py
File metadata and controls
45 lines (40 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright The IETF Trust 2021, All Rights Reserved
# -*- coding: utf-8 -*-
"""HedgeDoc API utilities tests"""
import requests_mock
from ietf.utils.tests import TestCase
from ietf.utils.hedgedoc import Note
class NoteTests(TestCase):
SAMPLE_MARKDOWN = ''.join((
'# Standard Markdown\n',
'This is a small sample of markdown text. It uses GFM-style line breaks.\n',
'\n',
'This is a second paragraph.\n',
'It has line breaks in GFM style.\n',
'And also some standard line breaks. \n',
'That is all.\n',
))
SAMPLE_MARKDOWN_OUTPUT = ''.join((
'# Standard Markdown {#standard-markdown}\n',
'\n',
'This is a small sample of markdown text. It uses GFM-style line breaks.\n',
'\n',
'This is a second paragraph. \n',
'It has line breaks in GFM style. \n',
'And also some standard line breaks. \n',
'That is all.\n',
'\n',
))
def test_retrieves_note(self):
with requests_mock.Mocker() as mock:
mock.get('https://notes.ietf.org/my_id/download', text=self.SAMPLE_MARKDOWN)
n = Note('my_id')
result = n.get_source()
self.assertEqual(result, self.SAMPLE_MARKDOWN_OUTPUT)
def test_uses_preprocess_class_method(self):
"""Imported text should be processed by the preprocess_source class method"""
with requests_mock.Mocker() as mock:
mock.get('https://notes.ietf.org/my_id/download', text=self.SAMPLE_MARKDOWN)
n = Note('my_id')
result = n.get_source()
self.assertEqual(result, Note.preprocess_source(self.SAMPLE_MARKDOWN))