Skip to content

Commit

Permalink
@Natim review
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Dec 15, 2016
1 parent 07ee078 commit 57bc447
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/test_pyramidhook.py
Expand Up @@ -218,8 +218,20 @@ def test_no_sniff_is_added_to_responses(self):
self.assertEqual(response.headers['X-Content-Type-Options'], 'nosniff')


test_service = Service(name="jardinet", path="/jardinet", traverse="/jardinet")
test_service.add_view('GET', lambda _:_)
test_service = Service(name="jardinet", path="/jardinet", traverse='/')
test_service.add_view('GET', lambda request: request.current_service.name)


class TestCurrentService(TestCase):
def setUp(self):
self.config = testing.setUp()
self.config.include("cornice")
self.config.scan("tests.test_pyramidhook")
self.app = TestApp(CatchErrors(self.config.make_wsgi_app()))

def test_current_service_on_request(self):
resp = self.app.get("/jardinet")
self.assertEqual(resp.json, "jardinet")


class TestRouteWithTraverse(TestCase):
Expand All @@ -229,10 +241,8 @@ def test_route_construction(self):
config.add_route = mock.MagicMock()

register_service_views(config, test_service)
self.assertTrue(
('traverse', '/jardinet'),
config.add_route.called_args,
)
config.add_route.assert_called_with('jardinet', '/jardinet',
traverse='/')

def test_route_with_prefix(self):
config = testing.setUp(settings={})
Expand Down

0 comments on commit 57bc447

Please sign in to comment.