mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
notify-api-412 use black to enforce python style standards
This commit is contained in:
@@ -11,10 +11,11 @@ from app.service.service_callback_api_schema import (
|
||||
|
||||
|
||||
def test_service_callback_api_schema_validates():
|
||||
under_test = {"url": "https://some_url.for_service",
|
||||
"bearer_token": "something_ten_chars",
|
||||
"updated_by_id": str(uuid.uuid4())
|
||||
}
|
||||
under_test = {
|
||||
"url": "https://some_url.for_service",
|
||||
"bearer_token": "something_ten_chars",
|
||||
"updated_by_id": str(uuid.uuid4()),
|
||||
}
|
||||
|
||||
validated = validate(under_test, update_service_callback_api_schema)
|
||||
assert validated == under_test
|
||||
@@ -22,26 +23,28 @@ def test_service_callback_api_schema_validates():
|
||||
|
||||
@pytest.mark.parametrize("url", ["not a url", "https not a url", "http://valid.com"])
|
||||
def test_service_callback_api_schema_errors_for_url_not_valid_url(url):
|
||||
under_test = {"url": url,
|
||||
"bearer_token": "something_ten_chars",
|
||||
"updated_by_id": str(uuid.uuid4())
|
||||
}
|
||||
under_test = {
|
||||
"url": url,
|
||||
"bearer_token": "something_ten_chars",
|
||||
"updated_by_id": str(uuid.uuid4()),
|
||||
}
|
||||
|
||||
with pytest.raises(ValidationError) as e:
|
||||
validate(under_test, update_service_callback_api_schema)
|
||||
errors = json.loads(str(e.value)).get('errors')
|
||||
errors = json.loads(str(e.value)).get("errors")
|
||||
assert len(errors) == 1
|
||||
assert errors[0]['message'] == "url is not a valid https url"
|
||||
assert errors[0]["message"] == "url is not a valid https url"
|
||||
|
||||
|
||||
def test_service_callback_api_schema_bearer_token_under_ten_char():
|
||||
under_test = {"url": "https://some_url.for_service",
|
||||
"bearer_token": "shorty",
|
||||
"updated_by_id": str(uuid.uuid4())
|
||||
}
|
||||
under_test = {
|
||||
"url": "https://some_url.for_service",
|
||||
"bearer_token": "shorty",
|
||||
"updated_by_id": str(uuid.uuid4()),
|
||||
}
|
||||
|
||||
with pytest.raises(ValidationError) as e:
|
||||
validate(under_test, update_service_callback_api_schema)
|
||||
errors = json.loads(str(e.value)).get('errors')
|
||||
errors = json.loads(str(e.value)).get("errors")
|
||||
assert len(errors) == 1
|
||||
assert errors[0]['message'] == "bearer_token shorty is too short"
|
||||
assert errors[0]["message"] == "bearer_token shorty is too short"
|
||||
|
||||
Reference in New Issue
Block a user