1import pytest 2from unit.applications.lang.python import TestApplicationPython 3from unit.option import option 4 5 6class TestPythonTargets(TestApplicationPython): 7 prerequisites = {'modules': {'python': 'all'}} 8 9 def test_python_targets(self): 10 assert 'success' in self.conf( 11 { 12 "listeners": {"*:7080": {"pass": "routes"}}, 13 "routes": [ 14 { 15 "match": {"uri": "/1"}, 16 "action": {"pass": "applications/targets/1"}, 17 }, 18 { 19 "match": {"uri": "/2"}, 20 "action": {"pass": "applications/targets/2"}, 21 }, 22 ], 23 "applications": { 24 "targets": { 25 "type": "python", 26 "working_directory": option.test_dir 27 + "/python/targets/", 28 "path": option.test_dir + '/python/targets/', 29 "targets": { 30 "1": { 31 "module": "wsgi", 32 "callable": "wsgi_target_a", 33 }, 34 "2": { 35 "module": "wsgi", 36 "callable": "wsgi_target_b", 37 }, 38 }, 39 } 40 }, 41 } 42 ) 43 44 resp = self.get(url='/1') 45 assert resp['status'] == 200 46 assert resp['body'] == '1' 47 48 resp = self.get(url='/2') 49 assert resp['status'] == 200 50 assert resp['body'] == '2' 51