-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_util_srte.py
More file actions
134 lines (106 loc) · 5.79 KB
/
test_util_srte.py
File metadata and controls
134 lines (106 loc) · 5.79 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import json
import os
import unittest
from contentstack_utils import Utils
from contentstack_utils.render.options import Options
from tests.mocks.supercharged.results import Results
def __is_json(file):
try:
json.dumps(file)
return True
except ValueError:
return False
def load_mock():
path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'mocks/supercharged', 'supercharged.json')
with open(path) as file:
return json.load(file)
class TestSuperchargedUtils(unittest.TestCase):
global _json_data # Note that the PyCharm warnings are not actual python errors
def setUp(self):
self._json_data = load_mock()
def test_plaintext_in_supercharged_dict_to_html(self):
array_str = ['plaintext']
response = Utils.json_to_html(self._json_data, array_str, Options())
self.assertEqual(Results.plainTextHtml, response)
def test_plaintext_in_supercharged_list_to_html(self):
array_str = ['plaintext_array']
response = Utils.json_to_html(self._json_data, array_str, Options())
self.assertEqual(Results.plainTextHtml, response)
def test_paragraph_in_supercharged_dict_to_html(self):
array_str = ['paragraph']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.paragraphHtml, response)
def test_h1_in_supercharged_dict_to_html(self):
array_str = ['h_one']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.h1Html, response)
def test_h2_in_supercharged_dict_to_html(self):
array_str = ['h_two']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.h2Html, response)
def test_h3_in_supercharged_dict_to_html(self):
array_str = ['h_three']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.h3Html, response)
def test_h4_in_supercharged_dict_to_html(self):
array_str = ['h_four']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.h4Html, response)
def test_h5_in_supercharged_dict_to_html(self):
array_str = ['h_five']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.h5Html, response)
def test_h6_in_supercharged_dict_to_html(self):
array_str = ['h_six']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.h6Html, response)
def test_order_list_in_supercharged_dict_to_html(self):
array_str = ['order_list']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.orderListHtml, response)
def test_un_order_list_in_supercharged_dict_to_html(self):
array_str = ['un_order_list']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.unorderListHtml, response)
def test_image_list_in_supercharged_dict_to_html(self):
array_str = ['img']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.imgHtml, response)
def test_table_list_in_supercharged_dict_to_html(self):
array_str = ['table']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.tableHtml, response)
def test_blockquote_list_in_supercharged_dict_to_html(self):
array_str = ['blockquote']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.blockquoteHtml, response)
def test_code_list_in_supercharged_dict_to_html(self):
array_str = ['code']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.codeHtml, response)
def test_linkin_list_in_supercharged_dict_to_html(self):
array_str = ['link']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.linkInPHtml, response)
def test_reference_list_in_supercharged_dict_to_html(self):
array_str = ['reference']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.refImgHtml, response)
def test_nested_order_list_in_supercharged_dict_to_html(self):
array_str = ['nested_order_list_with_fragment']
Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.nested_order_list_with_fragment, "<ol><li><fragment>List Item 1</fragment><ol><li>List Item 1.1</li><li>List Item 1.2</li><li>List Item 1.3</li></ol></li></ol>")
def test_reference_image_in_supercharged_dict_to_html(self):
array_str = ['reference']
response = Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.refImgHtml, response)
def test_nested_order_list_in_supercharged_dict_to_html(self):
array_str = ['nested_order_list_with_fragment']
Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.nested_order_list_with_fragment, "<ol><li><fragment>List Item 1</fragment><ol><li>List Item 1.1</li><li>List Item 1.2</li><li>List Item 1.3</li></ol></li></ol>")
def test_nested_unorder_list_in_supercharged_dict_to_html(self):
array_str = ['nested_unorder_list_with_fragment']
Utils.json_to_html([self._json_data], array_str, Options())
self.assertEqual(Results.nested_unorder_list_with_fragment, "<ul><li><fragment>List Item 1</fragment><ul><li>List Item 1.1</li><li>List Item 1.2</li><li>List Item 1.3</li></ul></li></ul>")