Skip to content

Commit

Permalink
Unittest for Mocking template_renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarun-Arora committed Jan 19, 2022
1 parent ba1c72b commit 4276f83
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_customized/TestControllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,18 @@ def test_customize_test_wrong_commit_hash(self, mock_user, mock_git, mock_reques
# Validate if View Works
self.assertEqual(response.status_code, 200)
self.assertIn("Wrong Commit Hash", str(response.data))

@mock.patch('flask.templating._render', return_value='')
def test_customize_mock_template_renderer(self, mock_user, mock_git, mock_requests, mock_renderer):
"""Test Access to Homepage gives Empty Response instead of 500 Error Page."""
with self.app.test_client() as c:
response = c.get('/')
self.assertEqual(response.data, b'')
self.assertEqual(response.status_code, 500)

def test_customize_without_mock_template_renderer(self, mock_user, mock_git, mock_requests):
"""Test Access to Homepage gives Internal Server Error Page."""
with self.app.test_client() as c:
response = c.get('/')
self.assertNotEqual(response.data, b'')
self.assertEqual(response.status_code, 500)

0 comments on commit 4276f83

Please sign in to comment.