Example #1
0
    def setUp(self):
        """
        Set up Flask app for testing
        """

        app.testing = True
        self.client = app.test_client()
        return super().setUp()
Example #2
0
 def setUp(self):
     app.testing = True
     self.client = app.test_client()
     return super().setUp()
Example #3
0
 def setUp(self):
     """
     Set up Flask app for testing
     """
     app.config["TESTING"] = True
     self.client = app.test_client()
Example #4
0
def client():
    with app.test_client() as client:
        yield client
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 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")
Example #8
0
 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")
Example #9
0
 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)