Skip to content
This repository has been archived by the owner on Jun 13, 2020. It is now read-only.

Commit

Permalink
Fix tests for LandingView by mocking flag_enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
willbarton committed Apr 20, 2017
1 parent 88d60da commit 5dd086c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions complaintdatabase/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ def setUp(self):
"""Every test needs access to the request factory."""
self.factory = RequestFactory()

def test_get_context_data_exist(self):
@patch('complaintdatabase.views.flag_enabled')
def test_get_context_data_exist(self, mock_flag_enabled):
"""Create an instance of a GET request."""
mock_flag_enabled.return_value = True
request = self.factory.get('/')
response = LandingView.as_view()(request)
self.assertEqual(response.status_code, 200)
Expand All @@ -31,8 +33,10 @@ def test_get_context_data_exist(self):
self.assertTrue('total_complaints' in response.context_data.keys())
self.assertTrue('timely_responses' in response.context_data.keys())

def test_demo_json(self):
@patch('complaintdatabase.views.flag_enabled')
def test_demo_json(self, mock_flag_enabled):
"""Test demo version of landing page"""
mock_flag_enabled.return_value = True
response = client.get(reverse("complaintdatabase:ccdb-demo",
kwargs={'demo_json': 'demo.json'}))
self.assertEqual(response.status_code, 200)
Expand Down

0 comments on commit 5dd086c

Please sign in to comment.