コード例 #1
0
    def test_index_content(self):
        client = app.test_client()
        url = '/'

        response = client.get(url)
        content_type = response.content_type
        self.assertEqual(content_type, 'application/json')
コード例 #2
0
    def test_index_route(self):
        client = app.test_client()
        url = '/'

        response = client.get(url)
        status_code = response.status_code
        self.assertEqual(status_code, 200)
コード例 #3
0
    def test_index_data(self):
        client = app.test_client()
        url = '/'

        response = client.get(url)
        data = response.data
        print(data)
        self.assertTrue(b'{"message":"hello, space!","status":"OK"}\n' in data)
コード例 #4
0
    def test_loc_empty_data_failure(self):
        client = app.test_client()
        url = '/api/v1/loc'

        mock_request_data = {}

        response = client.post(url, data=json.dumps(mock_request_data))
        self.assertTrue(
            b'{"message":"Internal Server Error","status_code":500}\n' in
            response.data)
コード例 #5
0
    def test_loc_route_success(self):
        client = app.test_client()
        url = '/api/v1/loc'

        mock_request_data = {
            "x": "123.12",
            "y": "456.56",
            "z": "789.89",
            "vel": "50.0"
        }

        response = client.post(url, data=json.dumps(mock_request_data))
        status_code = response.status_code
        self.assertEqual(status_code, 200)
コード例 #6
0
    def test_loc_response_success(self):
        client = app.test_client()
        url = '/api/v1/loc'

        mock_request_data = {
            "x": "123.12",
            "y": "456.56",
            "z": "789.89",
            "vel": "20.0"
        }
        response = client.post(url, data=json.dumps(mock_request_data))
        data = response.data
        self.assertTrue(
            b'{"loc":1389.57,"message":"Calculation Completed","status_code":200}\n'
            in data)
コード例 #7
0
    def test_loc_faulty_data_failure(self):
        client = app.test_client()
        url = '/api/v1/loc'

        mock_request_data = {
            "x": "123.12",
            "y": "456.56",
            "z": "south",
            "vel": ""
        }

        response = client.post(url, data=json.dumps(mock_request_data))
        self.assertTrue(
            b'{"message":{"vel":["Not a valid number."],"z":["Not a valid number."]},"status_code":422}\n'
            in response.data)
コード例 #8
0
ファイル: conftest.py プロジェクト: openculinary/planner
def client():
    return app.test_client()
コード例 #9
0
ファイル: test_app.py プロジェクト: sebasibarguen/convo
def client(app):
    """A test client for the app."""
    return app.test_client()
コード例 #10
0
def tester():
    with app.test_client() as tester:
        yield tester
コード例 #11
0
def test_returns_404_with_no_path():
    response = app.test_client().get("/")
    assert response.status_code == 404
コード例 #12
0
def test_returns_200_with_correct_path():
    response = app.test_client().get("/options")
    assert response.status_code == 200