xref: /unit/test/test_python_targets.py (revision 2055:84cb1ec94bae)
11873So.canty@f5.comfrom unit.applications.lang.python import TestApplicationPython
21873So.canty@f5.comfrom unit.option import option
31873So.canty@f5.com
41873So.canty@f5.com
51873So.canty@f5.comclass TestPythonTargets(TestApplicationPython):
61873So.canty@f5.com    prerequisites = {'modules': {'python': 'all'}}
71873So.canty@f5.com
81873So.canty@f5.com    def test_python_targets(self):
91873So.canty@f5.com        assert 'success' in self.conf(
101873So.canty@f5.com            {
111873So.canty@f5.com                "listeners": {"*:7080": {"pass": "routes"}},
121873So.canty@f5.com                "routes": [
131873So.canty@f5.com                    {
141873So.canty@f5.com                        "match": {"uri": "/1"},
151873So.canty@f5.com                        "action": {"pass": "applications/targets/1"},
161873So.canty@f5.com                    },
171873So.canty@f5.com                    {
181873So.canty@f5.com                        "match": {"uri": "/2"},
191873So.canty@f5.com                        "action": {"pass": "applications/targets/2"},
201873So.canty@f5.com                    },
211873So.canty@f5.com                ],
221873So.canty@f5.com                "applications": {
231873So.canty@f5.com                    "targets": {
24*2055Szelenkov@nginx.com                        "type": self.get_application_type(),
251873So.canty@f5.com                        "working_directory": option.test_dir
261873So.canty@f5.com                        + "/python/targets/",
271873So.canty@f5.com                        "path": option.test_dir + '/python/targets/',
281873So.canty@f5.com                        "targets": {
291873So.canty@f5.com                            "1": {
301873So.canty@f5.com                                "module": "wsgi",
311873So.canty@f5.com                                "callable": "wsgi_target_a",
321873So.canty@f5.com                            },
331873So.canty@f5.com                            "2": {
341873So.canty@f5.com                                "module": "wsgi",
351873So.canty@f5.com                                "callable": "wsgi_target_b",
361873So.canty@f5.com                            },
371873So.canty@f5.com                        },
381873So.canty@f5.com                    }
391873So.canty@f5.com                },
401873So.canty@f5.com            }
411873So.canty@f5.com        )
421873So.canty@f5.com
431873So.canty@f5.com        resp = self.get(url='/1')
441873So.canty@f5.com        assert resp['status'] == 200
451873So.canty@f5.com        assert resp['body'] == '1'
461873So.canty@f5.com
471873So.canty@f5.com        resp = self.get(url='/2')
481873So.canty@f5.com        assert resp['status'] == 200
491873So.canty@f5.com        assert resp['body'] == '2'
50