1from unit.control import TestControl 2 3 4class TestPHPBasic(TestControl): 5 prerequisites = {'modules': ['php']} 6 7 conf_app = { 8 "app": { 9 "type": "php", 10 "processes": {"spare": 0}, 11 "root": "/app", 12 "index": "index.php", 13 } 14 } 15 16 conf_basic = { 17 "listeners": {"*:7080": {"pass": "applications/app"}}, 18 "applications": conf_app, 19 } 20 21 def test_php_get_applications(self): 22 self.conf(self.conf_app, 'applications') 23 24 conf = self.conf_get() 25 26 self.assertEqual(conf['listeners'], {}, 'listeners') 27 self.assertEqual( 28 conf['applications'], 29 { 30 "app": { 31 "type": "php", 32 "processes": {"spare": 0}, 33 "root": "/app", 34 "index": "index.php", 35 } 36 }, 37 'applications', 38 ) 39
| 1from unit.control import TestControl 2 3 4class TestPHPBasic(TestControl): 5 prerequisites = {'modules': ['php']} 6 7 conf_app = { 8 "app": { 9 "type": "php", 10 "processes": {"spare": 0}, 11 "root": "/app", 12 "index": "index.php", 13 } 14 } 15 16 conf_basic = { 17 "listeners": {"*:7080": {"pass": "applications/app"}}, 18 "applications": conf_app, 19 } 20 21 def test_php_get_applications(self): 22 self.conf(self.conf_app, 'applications') 23 24 conf = self.conf_get() 25 26 self.assertEqual(conf['listeners'], {}, 'listeners') 27 self.assertEqual( 28 conf['applications'], 29 { 30 "app": { 31 "type": "php", 32 "processes": {"spare": 0}, 33 "root": "/app", 34 "index": "index.php", 35 } 36 }, 37 'applications', 38 ) 39
|
40 def test_php_get_applications_prefix(self): 41 self.conf(self.conf_app, 'applications') 42
| |
43 self.assertEqual( 44 self.conf_get('applications'), 45 { 46 "app": { 47 "type": "php", 48 "processes": {"spare": 0}, 49 "root": "/app", 50 "index": "index.php", 51 } 52 }, 53 'applications prefix', 54 ) 55
| 40 self.assertEqual( 41 self.conf_get('applications'), 42 { 43 "app": { 44 "type": "php", 45 "processes": {"spare": 0}, 46 "root": "/app", 47 "index": "index.php", 48 } 49 }, 50 'applications prefix', 51 ) 52
|
56 def test_php_get_applications_prefix_2(self): 57 self.conf(self.conf_app, 'applications') 58
| |
59 self.assertEqual( 60 self.conf_get('applications/app'), 61 { 62 "type": "php", 63 "processes": {"spare": 0}, 64 "root": "/app", 65 "index": "index.php", 66 }, 67 'applications prefix 2', 68 ) 69
| 53 self.assertEqual( 54 self.conf_get('applications/app'), 55 { 56 "type": "php", 57 "processes": {"spare": 0}, 58 "root": "/app", 59 "index": "index.php", 60 }, 61 'applications prefix 2', 62 ) 63
|
70 def test_php_get_applications_prefix_3(self): 71 self.conf(self.conf_app, 'applications') 72
| |
73 self.assertEqual(self.conf_get('applications/app/type'), 'php', 'type') 74 self.assertEqual( 75 self.conf_get('applications/app/processes/spare'), 76 0, 77 'spare processes', 78 ) 79 80 def test_php_get_listeners(self): 81 self.conf(self.conf_basic) 82 83 self.assertEqual( 84 self.conf_get()['listeners'], 85 {"*:7080": {"pass": "applications/app"}}, 86 'listeners', 87 ) 88
| 64 self.assertEqual(self.conf_get('applications/app/type'), 'php', 'type') 65 self.assertEqual( 66 self.conf_get('applications/app/processes/spare'), 67 0, 68 'spare processes', 69 ) 70 71 def test_php_get_listeners(self): 72 self.conf(self.conf_basic) 73 74 self.assertEqual( 75 self.conf_get()['listeners'], 76 {"*:7080": {"pass": "applications/app"}}, 77 'listeners', 78 ) 79
|
89 def test_php_get_listeners_prefix(self): 90 self.conf(self.conf_basic) 91
| |
92 self.assertEqual( 93 self.conf_get('listeners'), 94 {"*:7080": {"pass": "applications/app"}}, 95 'listeners prefix', 96 ) 97
| 80 self.assertEqual( 81 self.conf_get('listeners'), 82 {"*:7080": {"pass": "applications/app"}}, 83 'listeners prefix', 84 ) 85
|
98 def test_php_get_listeners_prefix_2(self): 99 self.conf(self.conf_basic) 100
| |
101 self.assertEqual( 102 self.conf_get('listeners/*:7080'), 103 {"pass": "applications/app"}, 104 'listeners prefix 2', 105 ) 106 107 def test_php_change_listener(self): 108 self.conf(self.conf_basic) 109 self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners') 110 111 self.assertEqual( 112 self.conf_get('listeners'), 113 {"*:7081": {"pass": "applications/app"}}, 114 'change listener', 115 ) 116 117 def test_php_add_listener(self): 118 self.conf(self.conf_basic) 119 self.conf({"pass": "applications/app"}, 'listeners/*:7082') 120 121 self.assertEqual( 122 self.conf_get('listeners'), 123 { 124 "*:7080": {"pass": "applications/app"}, 125 "*:7082": {"pass": "applications/app"}, 126 }, 127 'add listener', 128 ) 129 130 def test_php_change_application(self): 131 self.conf(self.conf_basic) 132 133 self.conf('30', 'applications/app/processes/max') 134 self.assertEqual( 135 self.conf_get('applications/app/processes/max'), 136 30, 137 'change application max', 138 ) 139 140 self.conf('"/www"', 'applications/app/root') 141 self.assertEqual( 142 self.conf_get('applications/app/root'), 143 '/www', 144 'change application root', 145 ) 146 147 def test_php_delete(self): 148 self.conf(self.conf_basic) 149
| 86 self.assertEqual( 87 self.conf_get('listeners/*:7080'), 88 {"pass": "applications/app"}, 89 'listeners prefix 2', 90 ) 91 92 def test_php_change_listener(self): 93 self.conf(self.conf_basic) 94 self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners') 95 96 self.assertEqual( 97 self.conf_get('listeners'), 98 {"*:7081": {"pass": "applications/app"}}, 99 'change listener', 100 ) 101 102 def test_php_add_listener(self): 103 self.conf(self.conf_basic) 104 self.conf({"pass": "applications/app"}, 'listeners/*:7082') 105 106 self.assertEqual( 107 self.conf_get('listeners'), 108 { 109 "*:7080": {"pass": "applications/app"}, 110 "*:7082": {"pass": "applications/app"}, 111 }, 112 'add listener', 113 ) 114 115 def test_php_change_application(self): 116 self.conf(self.conf_basic) 117 118 self.conf('30', 'applications/app/processes/max') 119 self.assertEqual( 120 self.conf_get('applications/app/processes/max'), 121 30, 122 'change application max', 123 ) 124 125 self.conf('"/www"', 'applications/app/root') 126 self.assertEqual( 127 self.conf_get('applications/app/root'), 128 '/www', 129 'change application root', 130 ) 131 132 def test_php_delete(self): 133 self.conf(self.conf_basic) 134
|
150 self.assertIn( 151 'error', 152 self.conf_delete('applications/app'), 153 'delete app before listener', 154 ) 155 self.assertIn( 156 'success', self.conf_delete('listeners/*:7080'), 'delete listener' 157 ) 158 self.assertIn( 159 'success', 160 self.conf_delete('applications/app'), 161 'delete app after listener', 162 ) 163 self.assertIn( 164 'error', self.conf_delete('applications/app'), 'delete app again' 165 )
| 135 self.assertIn('error', self.conf_delete('applications/app')) 136 self.assertIn('success', self.conf_delete('listeners/*:7080')) 137 self.assertIn('success', self.conf_delete('applications/app')) 138 self.assertIn('error', self.conf_delete('applications/app'))
|
166 167 def test_php_delete_blocks(self): 168 self.conf(self.conf_basic) 169
| 139 140 def test_php_delete_blocks(self): 141 self.conf(self.conf_basic) 142
|
170 self.assertIn( 171 'success', 172 self.conf_delete('listeners'), 173 'listeners delete', 174 )
| 143 self.assertIn('success', self.conf_delete('listeners')) 144 self.assertIn('success', self.conf_delete('applications'))
|
175
| 145
|
| 146 self.assertIn('success', self.conf(self.conf_app, 'applications'))
|
176 self.assertIn( 177 'success',
| 147 self.assertIn( 148 'success',
|
178 self.conf_delete('applications'), 179 'applications delete', 180 ) 181 182 self.assertIn( 183 'success', 184 self.conf(self.conf_app, 'applications'), 185 'listeners restore', 186 ) 187 188 self.assertIn( 189 'success',
| |
190 self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners'), 191 'applications restore', 192 ) 193
| 149 self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners'), 150 'applications restore', 151 ) 152
|
| 153
|
194if __name__ == '__main__': 195 TestPHPBasic.main()
| 154if __name__ == '__main__': 155 TestPHPBasic.main()
|