def test(self): from pyramid.interfaces import IRoutesMapper from papyrus_mapproxy import add_route config = self._makeOne(autocommit=True) view = lambda *arg: "OK" add_route(config, view) mapper = config.registry.getUtility(IRoutesMapper) routes = mapper.get_routes() self.assertEqual(len(routes), 1) self.assertEqual(routes[0].name, 'mapproxy') self.assertEqual(routes[0].pattern, '/mapproxy/*subpath') request_iface = self._getRouteRequestIface(config, 'mapproxy') self.assertNotEqual(request_iface, None) wrapper = self._getViewCallable(config, request_iface=request_iface) self.assertEqual(wrapper, view)
def test_mapproxy(self): from pyramid.request import Request from papyrus_mapproxy import (load_mapproxy_config, create_view_callable, add_route) mapproxy_config_file = self.config.get_settings().get('mapproxy.yaml') mapproxy_config = load_mapproxy_config(mapproxy_config_file) view = create_view_callable(mapproxy_config) add_route(self.config, view) context = DummyContext() request = Request({'wsgi.url_scheme': 'http', 'SERVER_NAME': 'foo', 'SERVER_PORT': '80'}) request.method = 'GET' response = view(context, request) from pyramid.response import Response self.assertTrue(isinstance(response, Response)) self.assertTrue('Welcome to MapProxy' in response.body)