Esempio n. 1
0
def test_with_empty_id():
    with pytest.raises(BadRequest) as info:
        kwargs = {"id": ""}
        InputJsonValidator(json_format=None)(func_mock)(**kwargs)
    assert info.value.code == 400
    assert info.value.data["message"] == "id is required"
    assert info.value.data["status"] == "error"
Esempio n. 2
0
def test_empty_json():
    with app.test_request_context():
        with mock.patch.object(request, 'get_json', return_value=None):
            with pytest.raises(BadRequest) as info:
                kwargs = {"id": 10}
                InputJsonValidator(
                    json_format=ridesharing_service_format)(func_mock)(
                        **kwargs)
            assert info.value.code == 400
            assert info.value.data["status"] == "invalid data"
Esempio n. 3
0
def test_json_without_klass():
    service = {
        'args': {
            'service_url': 'https://new_url.io',
            "rating_scale_min": 0,
            "crowfly_radius": 600,
            "api_key": "1235",
        }
    }
    with app.test_request_context():
        with mock.patch.object(request, 'get_json', return_value=service):
            kwargs = {"id": 10}
            with pytest.raises(BadRequest) as info:
                InputJsonValidator(
                    json_format=ridesharing_service_format)(func_mock)(
                        **kwargs)
            assert info.value.code == 400
            assert info.value.data["status"] == "invalid data"
            assert info.value.data[
                "message"] == "'klass' is a required property"