def setUp(self): """ Set up Flask app for testing """ app.testing = True self.client = app.test_client() return super().setUp()
def setUp(self): app.testing = True self.client = app.test_client() return super().setUp()
def setUp(self): """ Set up Flask app for testing """ app.config["TESTING"] = True self.client = app.test_client()
def client(): with app.test_client() as client: yield client
def test_missing_query_params(self): """ Test missing query params returns error and error message """ tester = app.test_client(self) response = tester.get(DUMMY_ROUTE_MISSING) self.assertEqual(response.status_code, 400) self.assertTrue(b'error' in response.data)
def test_incorrect_query_params(self): """ Test incorrect query params returns error and error message """ tester = app.test_client(self) response = tester.get(DUMMY_ROUTE_INCORRECT) self.assertEqual(response.status_code, 400) self.assertTrue(b'error' in response.data)
def test_response_data(self): """ Test response data is compressed correctly """ tester = app.test_client(self) response = tester.get(DUMMY_ROUTE) self.assertEqual(response.content_encoding, "gzip")
def test_response_type(self): """ Test response type is JSON """ tester = app.test_client(self) response = tester.get(DUMMY_ROUTE) self.assertEqual(response.content_type, "application/json")
def test_index(self): """ Test that Flask returns endpoint """ tester = app.test_client(self) response = tester.get(DUMMY_ROUTE) self.assertEqual(response.status_code, 200)