diff --git a/lostplaces/lostplaces_app/tests/views/__init__.py b/lostplaces/lostplaces_app/tests/views/__init__.py index 22455bf..5e991c6 100644 --- a/lostplaces/lostplaces_app/tests/views/__init__.py +++ b/lostplaces/lostplaces_app/tests/views/__init__.py @@ -1,13 +1,18 @@ from django.test import Client class ViewTestCaseMixin: + ''' + This is a mixni for testing views. It provides functionality to + test the context, forms and HTTP Response of responses. + Also works with django's ReqeustFactory. + ''' view = None def setUp(self): self.view_name = self.view.__name__ self. client = Client() - def _test_has_context_key(self, response, context_key): + def assertHasContextKey(self, response, context_key): self.assertTrue( context_key in response.context, msg='Expecting the context of %s to have an attribute \'%s\'' % ( self.view_name, @@ -16,7 +21,7 @@ class ViewTestCaseMixin: ) def assertHasForm(self, response, context_key, form_class): - self._test_has_context_key(response, context_key) + self.assertHasContextKey(response, context_key) self.assertEqual( type(response.context[context_key]), form_class, diff --git a/lostplaces/lostplaces_app/tests/views/test_place_views.py b/lostplaces/lostplaces_app/tests/views/test_place_views.py index 5b5c2a4..a987663 100644 --- a/lostplaces/lostplaces_app/tests/views/test_place_views.py +++ b/lostplaces/lostplaces_app/tests/views/test_place_views.py @@ -68,6 +68,6 @@ class TestPlaceListView(ViewTestCaseMixin, TestCase): self.client.login(username='testpeter', password='Develop123') response = self.client.get(reverse_lazy('place_list')) - self._test_has_context_key(response, 'map_config') + self.assertHasContextKey(response, 'map_config') \ No newline at end of file