def test_simple_match(self): self.mapper.connect('/foobar', action=self.route_handler, conditions=dict(method=['GET'])) environ = _environ(path='/foobar') handler.dispatch(environ, start_response, self.mapper) self.route_handler.assert_called_with(environ, start_response)
def test_simple_match_routing_args(self): self.mapper.connect('/foobar/{id}', action=self.route_handler, conditions=dict(method=['GET'])) environ = _environ(path='/foobar/%s' % uuidsentinel.foobar) handler.dispatch(environ, start_response, self.mapper) self.route_handler.assert_called_with(environ, start_response) self.assertEqual(uuidsentinel.foobar, environ['wsgiorg.routing_args'][1]['id'])
def test_405_headers(self): environ = _environ(path='/hello', method='POST') global headers, status headers = status = None def local_start_response(*args, **kwargs): global headers, status status = args[0] headers = {header[0]: header[1] for header in args[1]} handler.dispatch(environ, local_start_response, self.mapper) allow_header = headers['allow'] self.assertEqual('405 Method Not Allowed', status) self.assertEqual('GET', allow_header) # PEP 3333 requires that headers be whatever the native str # is in that version of Python. Never unicode. self.assertEqual(str, type(allow_header))