def test_sets_default_route_to_endpoint(self): endpoint = Stub('endpoint') expected_route = Route(path=None, endpoint=endpoint) self.router.setdefault(endpoint) verify(self.routes.setdefault).called_with(expected_route)
def test_accepts_default_controller(self): """can also be called like: router.map_controllers(path, controller)""" controller = object() expected_endpoint = Endpoint(controller) expected_route = Route('/the/path', endpoint=expected_endpoint) self.subject('/the/path', controller) verify(self.routes.add).called_with(expected_route)
def test_prints_greeting_to_full_name(self): self.greeter.greet('Greetings') verify(self.printer).called_with('Greetings, Justin Blake!')
def test_adds_an_endpoint_to_router_for_the_given_controllers(self): controller1, controller2 = object(), object() expected_endpoint = Endpoint(get=controller1, post=controller2) expected_route = Route(path='/path', endpoint=expected_endpoint) self.subject('/path', get=controller1, post=controller2) verify(self.routes.add).called_with(expected_route)
def test_adds_route_to_routes(self): endpoint = Stub('endpoint') expected_route = Route(path='/path', endpoint=endpoint) self.router.map_endpoint('/path', endpoint) verify(self.routes.add).called_with(expected_route)
def test_adds_route_to_the_routes_collection(self): route = object() self.router.add_route(route) verify(self.routes.add).called_with(route)
def test_sets_default_route_to_not_found_handler(self): default = Route(path=None, endpoint=not_found) verify(self.routes.setdefault).called_with(default)
def test_prints_greeting_to_full_name(self): self.greeter.greet("Greetings") verify(self.printer).called_with("Greetings, Justin Blake!")
def test_sets_greeter_result_as_response_text(self): response = self.controller(self.request, self.response) verify(response.write).called_with('the greeting')