test_python_basic.py (504:e9ebde982898) test_python_basic.py (507:fa714d76592b)
1import unittest
2import unit
3
4class TestUnitBasic(unit.TestUnitControl):
5
6 def setUpClass():
7 unit.TestUnit().check_modules('python')
8
9 conf_app = {
10 "app": {
11 "type": "python",
1import unittest
2import unit
3
4class TestUnitBasic(unit.TestUnitControl):
5
6 def setUpClass():
7 unit.TestUnit().check_modules('python')
8
9 conf_app = {
10 "app": {
11 "type": "python",
12 "workers": 1,
12 "processes": { "spare": 0 },
13 "path": "/app",
14 "module": "wsgi"
15 }
16 }
17
18 conf_basic = {
19 "listeners": {
20 "*:7080": {

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

39
40 conf = self.conf_get()
41
42 self.assertEqual(conf['listeners'], {}, 'listeners')
43 self.assertEqual(conf['applications'],
44 {
45 "app": {
46 "type": "python",
13 "path": "/app",
14 "module": "wsgi"
15 }
16 }
17
18 conf_basic = {
19 "listeners": {
20 "*:7080": {

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

39
40 conf = self.conf_get()
41
42 self.assertEqual(conf['listeners'], {}, 'listeners')
43 self.assertEqual(conf['applications'],
44 {
45 "app": {
46 "type": "python",
47 "workers": 1,
47 "processes": { "spare": 0 },
48 "path": "/app",
49 "module": "wsgi"
50 }
51 },
52 'applications')
53
54 def test_python_get_applications_prefix(self):
55 self.conf(self.conf_app, '/applications')
56
57 self.assertEqual(self.conf_get('/applications'),
58 {
59 "app": {
60 "type": "python",
48 "path": "/app",
49 "module": "wsgi"
50 }
51 },
52 'applications')
53
54 def test_python_get_applications_prefix(self):
55 self.conf(self.conf_app, '/applications')
56
57 self.assertEqual(self.conf_get('/applications'),
58 {
59 "app": {
60 "type": "python",
61 "workers": 1,
61 "processes": { "spare": 0 },
62 "path": "/app",
63 "module":"wsgi"
64 }
65 },
66 'applications prefix')
67
68 def test_python_get_applications_prefix_2(self):
69 self.conf(self.conf_app, '/applications')
70
71 self.assertEqual(self.conf_get('/applications/app'),
72 {
73 "type": "python",
62 "path": "/app",
63 "module":"wsgi"
64 }
65 },
66 'applications prefix')
67
68 def test_python_get_applications_prefix_2(self):
69 self.conf(self.conf_app, '/applications')
70
71 self.assertEqual(self.conf_get('/applications/app'),
72 {
73 "type": "python",
74 "workers": 1,
74 "processes": { "spare": 0 },
75 "path": "/app",
76 "module": "wsgi"
77 },
78 'applications prefix 2')
79
80 def test_python_get_applications_prefix_3(self):
81 self.conf(self.conf_app, '/applications')
82
83 self.assertEqual(self.conf_get('/applications/app/type'), 'python',
84 'type')
75 "path": "/app",
76 "module": "wsgi"
77 },
78 'applications prefix 2')
79
80 def test_python_get_applications_prefix_3(self):
81 self.conf(self.conf_app, '/applications')
82
83 self.assertEqual(self.conf_get('/applications/app/type'), 'python',
84 'type')
85 self.assertEqual(self.conf_get('/applications/app/workers'), 1,
86 'workers')
85 self.assertEqual(self.conf_get('/applications/app/processes/spare'), 0,
86 'spare')
87
88 def test_python_get_listeners(self):
89 self.conf(self.conf_basic)
90
91 self.assertEqual(self.conf_get()['listeners'],
92 {"*:7080":{"application":"app"}}, 'listeners')
93
94 def test_python_get_listeners_prefix(self):

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

123 "application": "app"
124 }
125 },
126 'add listener')
127
128 def test_python_change_application(self):
129 self.conf(self.conf_basic)
130
87
88 def test_python_get_listeners(self):
89 self.conf(self.conf_basic)
90
91 self.assertEqual(self.conf_get()['listeners'],
92 {"*:7080":{"application":"app"}}, 'listeners')
93
94 def test_python_get_listeners_prefix(self):

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

123 "application": "app"
124 }
125 },
126 'add listener')
127
128 def test_python_change_application(self):
129 self.conf(self.conf_basic)
130
131 self.conf('30', '/applications/app/workers')
132 self.assertEqual(self.conf_get('/applications/app/workers'), 30,
133 'change application workers')
131 self.conf('30', '/applications/app/processes/max')
132 self.assertEqual(self.conf_get('/applications/app/processes/max'), 30,
133 'change application max')
134
135 self.conf('"/www"', '/applications/app/path')
136 self.assertEqual(self.conf_get('/applications/app/path'), '/www',
137 'change application path')
138
139 def test_python_delete(self):
140 self.conf(self.conf_basic)
141
142 self.assertIn('error', self.conf_delete('/applications/app'),
143 'delete app before listener')
144 self.assertIn('success', self.conf_delete('/listeners/*:7080'),
145 'delete listener')
146 self.assertIn('success', self.conf_delete('/applications/app'),
147 'delete app after listener')
148 self.assertIn('error', self.conf_delete('/applications/app'),
149 'delete app again')
150
151if __name__ == '__main__':
152 unittest.main()
134
135 self.conf('"/www"', '/applications/app/path')
136 self.assertEqual(self.conf_get('/applications/app/path'), '/www',
137 'change application path')
138
139 def test_python_delete(self):
140 self.conf(self.conf_basic)
141
142 self.assertIn('error', self.conf_delete('/applications/app'),
143 'delete app before listener')
144 self.assertIn('success', self.conf_delete('/listeners/*:7080'),
145 'delete listener')
146 self.assertIn('success', self.conf_delete('/applications/app'),
147 'delete app after listener')
148 self.assertIn('error', self.conf_delete('/applications/app'),
149 'delete app again')
150
151if __name__ == '__main__':
152 unittest.main()