1
1
import unittest
2
-
2
+
3
3
from TM1py import Chore , ChoreStartTime , ChoreFrequency , ChoreTask
4
-
5
-
6
- class TestChore (unittest .TestCase ):
7
- chore = Chore (
4
+ from TM1py .Objects import Chore
5
+
6
+ class TestChore (unittest .TestCase ):
7
+ def setUp (self ):
8
+ self .chore = Chore (
8
9
name = "chore" ,
9
10
start_time = ChoreStartTime (2023 , 8 , 4 , 10 , 0 , 0 ),
10
11
dst_sensitivity = False ,
@@ -30,11 +31,96 @@ class TestChore(unittest.TestCase):
30
31
31
32
def test_from_dict_and_construct_body (self ):
32
33
text = self .chore .body
33
-
34
+
34
35
chore = Chore .from_json (text )
35
-
36
+
36
37
self .assertEqual (self .chore , chore )
38
+
39
+ def test_insert_task_as_step_0 (self ):
40
+ self .chore .insert_task (
41
+ ChoreTask (
42
+ step = 0 ,
43
+ process_name = "}bedrock.cube.clone" ,
44
+ parameters = [
45
+ {'Name' : 'pLogOutput' , 'Value' : 0 },
46
+ {'Name' : 'pStrictErrorHandling' , 'Value' : 1 },
47
+ {'Name' : 'pWaitSec' , 'Value' : 5 }]))
48
+ expected_chore = Chore (
49
+ name = "chore" ,
50
+ start_time = ChoreStartTime (2023 , 8 , 4 , 10 , 0 , 0 ),
51
+ dst_sensitivity = False ,
52
+ active = True ,
53
+ execution_mode = "SingleCommit" ,
54
+ frequency = ChoreFrequency (1 , 0 , 0 , 0 ),
55
+ tasks = [
56
+ ChoreTask (
57
+ step = 0 ,
58
+ process_name = "}bedrock.cube.clone" ,
59
+ parameters = [
60
+ {'Name' : 'pLogOutput' , 'Value' : 0 },
61
+ {'Name' : 'pStrictErrorHandling' , 'Value' : 1 },
62
+ {'Name' : 'pWaitSec' , 'Value' : 5 }]),
63
+ ChoreTask (
64
+ step = 1 ,
65
+ process_name = "}bedrock.server.wait" ,
66
+ parameters = [
67
+ {'Name' : 'pLogOutput' , 'Value' : 0 },
68
+ {'Name' : 'pStrictErrorHandling' , 'Value' : 1 },
69
+ {'Name' : 'pWaitSec' , 'Value' : 4 }]),
37
70
38
-
71
+ ChoreTask (
72
+ step = 2 ,
73
+ process_name = "}bedrock.server.wait" ,
74
+ parameters = [
75
+ {'Name' : 'pLogOutput' , 'Value' : 0 },
76
+ {'Name' : 'pStrictErrorHandling' , 'Value' : 1 },
77
+ {'Name' : 'pWaitSec' , 'Value' : 5 }]),
78
+ ])
79
+ self .assertEqual (self .chore , expected_chore )
80
+
81
+ def test_insert_task_as_step_1 (self ):
82
+ self .chore .insert_task (
83
+ ChoreTask (
84
+ step = 1 ,
85
+ process_name = "}bedrock.cube.clone" ,
86
+ parameters = [
87
+ {'Name' : 'pLogOutput' , 'Value' : 0 },
88
+ {'Name' : 'pStrictErrorHandling' , 'Value' : 1 },
89
+ {'Name' : 'pWaitSec' , 'Value' : 5 }]))
90
+ expected_chore = Chore (
91
+ name = "chore" ,
92
+ start_time = ChoreStartTime (2023 , 8 , 4 , 10 , 0 , 0 ),
93
+ dst_sensitivity = False ,
94
+ active = True ,
95
+ execution_mode = "SingleCommit" ,
96
+ frequency = ChoreFrequency (1 , 0 , 0 , 0 ),
97
+ tasks = [
98
+ ChoreTask (
99
+ step = 0 ,
100
+ process_name = "}bedrock.server.wait" ,
101
+ parameters = [
102
+ {'Name' : 'pLogOutput' , 'Value' : 0 },
103
+ {'Name' : 'pStrictErrorHandling' , 'Value' : 1 },
104
+ {'Name' : 'pWaitSec' , 'Value' : 4 }]),
105
+ ChoreTask (
106
+ step = 1 ,
107
+ process_name = "}bedrock.cube.clone" ,
108
+ parameters = [
109
+ {'Name' : 'pLogOutput' , 'Value' : 0 },
110
+ {'Name' : 'pStrictErrorHandling' , 'Value' : 1 },
111
+ {'Name' : 'pWaitSec' , 'Value' : 5 }]),
112
+ ChoreTask (
113
+ step = 2 ,
114
+ process_name = "}bedrock.server.wait" ,
115
+ parameters = [
116
+ {'Name' : 'pLogOutput' , 'Value' : 0 },
117
+ {'Name' : 'pStrictErrorHandling' , 'Value' : 1 },
118
+ {'Name' : 'pWaitSec' , 'Value' : 5 }]),
119
+ ])
120
+ self .assertEqual (self .chore , expected_chore )
121
+
122
+
39
123
if __name__ == '__main__' :
40
124
unittest .main ()
125
+
126
+
0 commit comments