-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_blendomaticutil.py
88 lines (65 loc) · 2.98 KB
/
test_blendomaticutil.py
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
import unittest
import blendomaticutil
class TestUtils(unittest.TestCase):
def test_input_parser(self):
input_objects = "[obj1, obj2]"
obj_list = blendomaticutil.parse_list_string(input_objects)
self.assertEqual(obj_list, [["obj1", "obj2"]])
input_objects = "obj1, obj2"
obj_list = blendomaticutil.parse_list_string(input_objects)
self.assertEqual(obj_list, [["obj1"], ["obj2"]])
# does combined also work ?
input_objects = "obj1, obj2, [ obj3 , obj4 ]"
obj_list = blendomaticutil.parse_list_string(input_objects)
self.assertEqual(obj_list, [["obj1"], ["obj2"], ["obj3", "obj4"]])
def test_input_output_mapping(self):
input_objects = "[obj1, obj2]"
output_files = "out.obj"
combined = blendomaticutil.map_inputs_to_ouputs(
input_objects, output_files)
self.assertEqual(len(combined), 1)
first_inputs = combined[0][0]
self.assertEqual("obj1", first_inputs[0])
self.assertEqual("obj2", first_inputs[1])
first_outputs = combined[0][1]
self.assertEqual(len(first_outputs), 1)
self.assertEqual("out.obj", first_outputs[0])
def test_input_output_mapping_non_list_syntax(self):
input_objects = "obj1, obj2"
output_files = "out1.obj, out2.obj"
combined = blendomaticutil.map_inputs_to_ouputs(
input_objects, output_files)
self.assertEqual(len(combined), 2)
first_inputs = combined[0][0]
self.assertEqual("obj1", first_inputs[0])
first_outputs = combined[0][1]
self.assertEqual(len(first_outputs), 1)
self.assertEqual("out1.obj", first_outputs[0])
first_inputs = combined[1][0]
self.assertEqual("obj2", first_inputs[0])
first_outputs = combined[1][1]
self.assertEqual(len(first_outputs), 1)
self.assertEqual("out2.obj", first_outputs[0])
def test_input_output_mapping_multiple_inputs(self):
input_objects = "[obj1, obj2], [obj3]"
some_options = "[23], [24]"
output_files = "[out1.obj], [out2.obj]"
out_lists = blendomaticutil.map_inputs_to_ouputs(
input_objects, some_options, output_files)
self.assertEqual(len(out_lists), 2)
first_inputs = out_lists[0]
self.assertEqual("obj1", first_inputs[0][0])
self.assertEqual("obj2", first_inputs[0][1])
first_inputs = out_lists[1]
self.assertEqual("24", first_inputs[1][0])
def test_input_output_mapping_interpolate(self):
input_objects = "[obj1, obj2], [obj3]"
some_options = "23"
output_files = "[out1.obj], [out2.obj]"
out_lists = blendomaticutil.map_inputs_to_ouputs(
input_objects, some_options, output_files)
first_inputs = out_lists[0]
# should have been extrapolated, test for it
self.assertEqual("23", first_inputs[1][0])
first_inputs = out_lists[1]
self.assertEqual("23", first_inputs[1][0])