def test_dont_check_files(self): request = self.factory.get(reverse(views.status)) response = views.status(request) response_json = json.loads(response.content) self.assertTrue( "quiesce file doesn't exist" not in response_json) self.assertTrue( 'Django Databases Health Check' in response_json) db_names = response_json['Django Databases Health Check']['details'] self.assertTrue( all(connection.alias in db_names for connection in connections.all())) self.assertEqual(response.status_code, 200)
def test_no_checks_raises_200(self): request = self.factory.get(reverse(views.status)) response = views.status(request) response = { 'content': json.loads(response.content), 'status': response.status_code, } expected_response = { 'content': 'There were no checks.', 'status': 200, } self.assertEqual(response, expected_response)
def test_failed_check(self): request = self.factory.get(reverse(views.status)) response = views.status(request) response = { 'content': json.loads(response.content.decode()), 'status': response.status_code, } expected_response = { 'content': { "quiesce file doesn't exist": { 'details': { '/usr/bin/env': 'FILE EXISTS' }, 'status': 'FAILED' } }, 'status': 500, } self.assertEqual(response, expected_response)
def test_default_checks(self): request = self.factory.get(reverse(views.status)) response = views.status(request) self.assertEqual(response.status_code, 200)