test_python_basic.py (1165:998b521bbdb8) test_python_basic.py (1453:71af60a59338)
1from unit.control import TestControl
2
3
4class TestPythonBasic(TestControl):
5 prerequisites = {'modules': ['python']}
6
7 conf_app = {
8 "app": {

--- 5 unchanged lines hidden (view full) ---

14 }
15
16 conf_basic = {
17 "listeners": {"*:7080": {"pass": "applications/app"}},
18 "applications": conf_app,
19 }
20
21 def test_python_get_empty(self):
1from unit.control import TestControl
2
3
4class TestPythonBasic(TestControl):
5 prerequisites = {'modules': ['python']}
6
7 conf_app = {
8 "app": {

--- 5 unchanged lines hidden (view full) ---

14 }
15
16 conf_basic = {
17 "listeners": {"*:7080": {"pass": "applications/app"}},
18 "applications": conf_app,
19 }
20
21 def test_python_get_empty(self):
22 self.assertEqual(
23 self.conf_get(), {'listeners': {}, 'applications': {}}, 'empty'
24 )
22 self.assertEqual(self.conf_get(), {'listeners': {}, 'applications': {}})
23 self.assertEqual(self.conf_get('listeners'), {})
24 self.assertEqual(self.conf_get('applications'), {})
25
25
26 def test_python_get_prefix_listeners(self):
27 self.assertEqual(self.conf_get('listeners'), {}, 'listeners prefix')
28
29 def test_python_get_prefix_applications(self):
30 self.assertEqual(
31 self.conf_get('applications'), {}, 'applications prefix'
32 )
33
34 def test_python_get_applications(self):
35 self.conf(self.conf_app, 'applications')
36
37 conf = self.conf_get()
38
39 self.assertEqual(conf['listeners'], {}, 'listeners')
40 self.assertEqual(
41 conf['applications'],
42 {
43 "app": {
44 "type": "python",
45 "processes": {"spare": 0},
46 "path": "/app",
47 "module": "wsgi",
48 }
49 },
50 'applications',
51 )
52
26 def test_python_get_applications(self):
27 self.conf(self.conf_app, 'applications')
28
29 conf = self.conf_get()
30
31 self.assertEqual(conf['listeners'], {}, 'listeners')
32 self.assertEqual(
33 conf['applications'],
34 {
35 "app": {
36 "type": "python",
37 "processes": {"spare": 0},
38 "path": "/app",
39 "module": "wsgi",
40 }
41 },
42 'applications',
43 )
44
53 def test_python_get_applications_prefix(self):
54 self.conf(self.conf_app, 'applications')
55
56 self.assertEqual(
57 self.conf_get('applications'),
58 {
59 "app": {
60 "type": "python",
61 "processes": {"spare": 0},
62 "path": "/app",
63 "module": "wsgi",
64 }
65 },
66 'applications prefix',
67 )
68
45 self.assertEqual(
46 self.conf_get('applications'),
47 {
48 "app": {
49 "type": "python",
50 "processes": {"spare": 0},
51 "path": "/app",
52 "module": "wsgi",
53 }
54 },
55 'applications prefix',
56 )
57
69 def test_python_get_applications_prefix_2(self):
70 self.conf(self.conf_app, 'applications')
71
72 self.assertEqual(
73 self.conf_get('applications/app'),
74 {
75 "type": "python",
76 "processes": {"spare": 0},
77 "path": "/app",
78 "module": "wsgi",
79 },
80 'applications prefix 2',
81 )
82
58 self.assertEqual(
59 self.conf_get('applications/app'),
60 {
61 "type": "python",
62 "processes": {"spare": 0},
63 "path": "/app",
64 "module": "wsgi",
65 },
66 'applications prefix 2',
67 )
68
83 def test_python_get_applications_prefix_3(self):
84 self.conf(self.conf_app, 'applications')
85
86 self.assertEqual(
87 self.conf_get('applications/app/type'), 'python', 'type'
88 )
89 self.assertEqual(
90 self.conf_get('applications/app/processes/spare'), 0, 'spare'
91 )
92
93 def test_python_get_listeners(self):
94 self.conf(self.conf_basic)
95
96 self.assertEqual(
97 self.conf_get()['listeners'],
98 {"*:7080": {"pass": "applications/app"}},
99 'listeners',
100 )
101
69 self.assertEqual(
70 self.conf_get('applications/app/type'), 'python', 'type'
71 )
72 self.assertEqual(
73 self.conf_get('applications/app/processes/spare'), 0, 'spare'
74 )
75
76 def test_python_get_listeners(self):
77 self.conf(self.conf_basic)
78
79 self.assertEqual(
80 self.conf_get()['listeners'],
81 {"*:7080": {"pass": "applications/app"}},
82 'listeners',
83 )
84
102 def test_python_get_listeners_prefix(self):
103 self.conf(self.conf_basic)
104
105 self.assertEqual(
106 self.conf_get('listeners'),
107 {"*:7080": {"pass": "applications/app"}},
108 'listeners prefix',
109 )
110
85 self.assertEqual(
86 self.conf_get('listeners'),
87 {"*:7080": {"pass": "applications/app"}},
88 'listeners prefix',
89 )
90
111 def test_python_get_listeners_prefix_2(self):
112 self.conf(self.conf_basic)
113
114 self.assertEqual(
115 self.conf_get('listeners/*:7080'),
116 {"pass": "applications/app"},
117 'listeners prefix 2',
118 )
119
120 def test_python_change_listener(self):
121 self.conf(self.conf_basic)

--- 33 unchanged lines hidden (view full) ---

155 self.conf_get('applications/app/path'),
156 '/www',
157 'change application path',
158 )
159
160 def test_python_delete(self):
161 self.conf(self.conf_basic)
162
91 self.assertEqual(
92 self.conf_get('listeners/*:7080'),
93 {"pass": "applications/app"},
94 'listeners prefix 2',
95 )
96
97 def test_python_change_listener(self):
98 self.conf(self.conf_basic)

--- 33 unchanged lines hidden (view full) ---

132 self.conf_get('applications/app/path'),
133 '/www',
134 'change application path',
135 )
136
137 def test_python_delete(self):
138 self.conf(self.conf_basic)
139
163 self.assertIn(
164 'error',
165 self.conf_delete('applications/app'),
166 'delete app before listener',
167 )
168 self.assertIn(
169 'success', self.conf_delete('listeners/*:7080'), 'delete listener'
170 )
171 self.assertIn(
172 'success',
173 self.conf_delete('applications/app'),
174 'delete app after listener',
175 )
176 self.assertIn(
177 'error', self.conf_delete('applications/app'), 'delete app again'
178 )
140 self.assertIn('error', self.conf_delete('applications/app'))
141 self.assertIn('success', self.conf_delete('listeners/*:7080'))
142 self.assertIn('success', self.conf_delete('applications/app'))
143 self.assertIn('error', self.conf_delete('applications/app'))
179
180 def test_python_delete_blocks(self):
181 self.conf(self.conf_basic)
182
144
145 def test_python_delete_blocks(self):
146 self.conf(self.conf_basic)
147
183 self.assertIn(
184 'success',
185 self.conf_delete('listeners'),
186 'listeners delete',
187 )
148 self.assertIn('success', self.conf_delete('listeners'))
149 self.assertIn('success', self.conf_delete('applications'))
188
150
151 self.assertIn('success', self.conf(self.conf_app, 'applications'))
189 self.assertIn(
190 'success',
152 self.assertIn(
153 'success',
191 self.conf_delete('applications'),
192 'applications delete',
193 )
194
195 self.assertIn(
196 'success',
197 self.conf(self.conf_app, 'applications'),
198 'listeners restore',
199 )
200
201 self.assertIn(
202 'success',
203 self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners'),
204 'applications restore',
205 )
206
207
208if __name__ == '__main__':
209 TestPythonBasic.main()
154 self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners'),
155 'applications restore',
156 )
157
158
159if __name__ == '__main__':
160 TestPythonBasic.main()