From 060d929d94f7dcadfd5ef0142e0d51dc26cb9ef9 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 20 Jan 2016 19:28:02 +0000 Subject: [PATCH] Added tests for project reverser --- project/common/tests.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/project/common/tests.py b/project/common/tests.py index 7ed1e4d..ab1a5fb 100644 --- a/project/common/tests.py +++ b/project/common/tests.py @@ -14,3 +14,15 @@ class CustomTemplateTestCase(TestCase): response = self.client.get(reverse(self.template)) for item in ['html_title', 'body_class', 'js_redirect']: self.assertIn(item, response.context) + + +class ReverserTestCase(TestCase): + REVERSER_IDENT = 'reverser:reverser' + def test_reverser(self): + response = self.client.post(reverse(self.REVERSER_IDENT), data={'ident': 'pages:index'}) + self.assertEqual(response.status_code, 302) + self.assertEqual(response.data, reverse('pages:index')) + + def test_invalid_reverser(self): + response = self.client.post(reverse(self.REVERSER_IDENT), data={'ident': 'pages:i-dont-exist'}) + self.assertEqual(response.status_code, 404)