1
|
|
|
from fastest.bodies.test_case_template_builder import case_generator |
2
|
|
|
from fastest.bodies.test_case_template_builder import create_assertion_test |
3
|
|
|
from fastest.bodies.test_case_template_builder import create_naive_test_case |
4
|
|
|
from fastest.bodies.test_case_template_builder import create_type_test_case |
5
|
|
|
from fastest.bodies.test_case_template_builder import create_type_test_case_if_params |
6
|
|
|
from fastest.bodies.test_case_template_builder import get_empty_of_type |
7
|
|
|
from fastest.bodies.test_case_template_builder import get_params_list |
8
|
|
|
from fastest.bodies.test_case_template_builder import is_type_test_ready |
9
|
|
|
from fastest.constants import TestBodies |
10
|
|
|
import unittest |
11
|
|
|
|
12
|
|
|
class TestTestCaseTemplateBuilderCaseGenerator(unittest.TestCase): |
13
|
|
|
def test__case_generator__72ADA0717A(self): |
14
|
|
|
self.assertEqual(case_generator('a55eff11-ed51-ecb37-ccba'), 'A55EFF11ED') |
15
|
|
|
|
16
|
|
|
class TestTestCaseTemplateBuilderGetEmptyOfType(unittest.TestCase): |
17
|
|
|
def test__get_empty_of_type__9EB02075E4(self): |
18
|
|
|
self.assertEqual(get_empty_of_type('str'), "''") |
19
|
|
|
def test__get_empty_of_type__9B37BF7153(self): |
20
|
|
|
self.assertEqual(get_empty_of_type('???'), None) |
21
|
|
|
|
22
|
|
|
class TestTestCaseTemplateBuilderGetParamsList(unittest.TestCase): |
23
|
|
|
def test__get_params_list__57DA4784AF(self): |
24
|
|
|
self.assertEqual(get_params_list(['str', 'str', 'list', 'dict']), ["''", "''", '[]', '{}']) |
25
|
|
|
def test__get_params_list__3221AE3ADE(self): |
26
|
|
|
self.assertEqual(get_params_list(['str', '???']), ["''"]) |
27
|
|
|
|
28
|
|
|
class TestTestCaseTemplateBuilderCreateTypeTestCase(unittest.TestCase): |
29
|
|
|
def test__create_type_test_case__B9C103DF1B(self): |
30
|
|
|
function_object = { |
31
|
|
|
'tests': { |
32
|
|
|
'return': 'str' |
33
|
|
|
}, |
34
|
|
|
'name': 'function_1' |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
params = ['str', 'str'] |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
self.assertEqual(create_type_test_case(function_object, params), TestBodies.TYPE_TEST_CASE_1) |
41
|
|
|
|
42
|
|
|
class TestTestCaseTemplateBuilderCreateTypeTestCaseIfParams(unittest.TestCase): |
43
|
|
|
def test__create_type_test_case_if_params__772EAEC008(self): |
44
|
|
|
function_object = { |
45
|
|
|
'tests': { |
46
|
|
|
'return': 'str' |
47
|
|
|
}, |
48
|
|
|
'name': 'function_1' |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
params = ['str', 'str'] |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
self.assertEqual(create_type_test_case_if_params(function_object, params), TestBodies.TYPE_TEST_CASE_2) |
55
|
|
|
|
56
|
|
|
class TestTestCaseTemplateBuilderIsTypeTestReady(unittest.TestCase): |
57
|
|
|
def test__is_type_test_ready__415EA1D907(self): |
58
|
|
|
function_object_1 = { |
59
|
|
|
'tests': { |
60
|
|
|
'return': 'str' |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
function_object_2 = {'tests': {}} |
65
|
|
|
|
66
|
|
|
params = ['str', 'str'] |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
self.assertEqual(is_type_test_ready(function_object_1, params), True) |
70
|
|
|
def test__is_type_test_ready__91E5C34C00(self): |
71
|
|
|
function_object_1 = { |
72
|
|
|
'tests': { |
73
|
|
|
'return': 'str' |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
function_object_2 = {'tests': {}} |
78
|
|
|
|
79
|
|
|
params = ['str', 'str'] |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
self.assertEqual(is_type_test_ready(function_object_2, params), False) |
83
|
|
|
def test__is_type_test_ready__0117E5B237(self): |
84
|
|
|
function_object_1 = { |
85
|
|
|
'tests': { |
86
|
|
|
'return': 'str' |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
function_object_2 = {'tests': {}} |
91
|
|
|
|
92
|
|
|
params = ['str', 'str'] |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
self.assertEqual(is_type_test_ready(function_object_1, []), False) |
96
|
|
|
|
97
|
|
|
class TestTestCaseTemplateBuilderCreateAssertionTest(unittest.TestCase): |
98
|
|
|
def test__create_assertion_test__2D20F4EA49(self): |
99
|
|
|
function_object_1 = { |
100
|
|
|
'tests': { |
101
|
|
|
'variables': ['a = 5'] |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
function_object_2 = {'tests': {'variables': []}} |
106
|
|
|
|
107
|
|
|
params = ['str', 'str'] |
108
|
|
|
|
109
|
|
|
|
110
|
|
|
self.assertEqual(create_assertion_test(function_object_1), TestBodies.ASSERTION_TEST_1) |
111
|
|
|
def test__create_assertion_test__4ACD8132A4(self): |
112
|
|
|
function_object_1 = { |
113
|
|
|
'tests': { |
114
|
|
|
'variables': ['a = 5'] |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
function_object_2 = {'tests': {'variables': []}} |
119
|
|
|
|
120
|
|
|
params = ['str', 'str'] |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
self.assertEqual(create_assertion_test(function_object_2), '') |
124
|
|
|
|
125
|
|
|
class TestTestCaseTemplateBuilderCreateNaiveTestCase(unittest.TestCase): |
126
|
|
|
def test__create_naive_test_case__64882A9F1F(self): |
127
|
|
|
function_object = { |
128
|
|
|
'tests': { |
129
|
|
|
'return': 'str', |
130
|
|
|
'variables': ['a = 5'] |
131
|
|
|
}, |
132
|
|
|
'name': 'function_1' |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
test = { |
136
|
|
|
'from': 'function_1', |
137
|
|
|
'expect': '2' |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
test_id = 'a55eff11-ed51-ecb37-ccba' |
141
|
|
|
|
142
|
|
|
|
143
|
|
|
self.assertEqual(create_naive_test_case(function_object, test, test_id), TestBodies.NAIVE_TEST_RESULT) |
144
|
|
|
|