Skip to content

Commit

Permalink
made tests always pass
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Jun 16, 2021
1 parent c149f08 commit 54b5ad5
Showing 1 changed file with 67 additions and 30 deletions.
97 changes: 67 additions & 30 deletions tests/databases/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from io import BytesIO
from unittest import mock
from zipfile import is_zipfile, ZipFile
from operator import itemgetter

import prison
import pytest
Expand Down Expand Up @@ -1674,38 +1675,74 @@ def test_validate_parameters_invalid_payload_schema(self):
response = json.loads(rv.data.decode("utf-8"))

assert rv.status_code == 422
assert response == {
"errors": [
{
"message": "Missing data for required field.",
"error_type": "INVALID_PAYLOAD_SCHEMA_ERROR",
"level": "error",
"extra": {
"invalid": ["engine"],
"issue_codes": [
{
"code": 1020,
"message": "Issue 1020 - The submitted payload has the incorrect schema.",
}
],
invalid_schema = response["errors"][0]["extra"]["invalid"][0]
# This is done because this array of errors does not have a deterministic order
if invalid_schema == "engine":
assert response == {
"errors": [
{
"message": "Missing data for required field.",
"error_type": "INVALID_PAYLOAD_SCHEMA_ERROR",
"level": "error",
"extra": {
"invalid": ["engine"],
"issue_codes": [
{
"code": 1020,
"message": "Issue 1020 - The submitted payload has the incorrect schema.",
}
],
},
},
},
{
"message": "Missing data for required field.",
"error_type": "INVALID_PAYLOAD_SCHEMA_ERROR",
"level": "error",
"extra": {
"invalid": ["configuration_method"],
"issue_codes": [
{
"code": 1020,
"message": "Issue 1020 - The submitted payload has the incorrect schema.",
}
],
{
"message": "Missing data for required field.",
"error_type": "INVALID_PAYLOAD_SCHEMA_ERROR",
"level": "error",
"extra": {
"invalid": ["configuration_method"],
"issue_codes": [
{
"code": 1020,
"message": "Issue 1020 - The submitted payload has the incorrect schema.",
}
],
},
},
},
]
}
]
}
else:
assert response == {
"errors": [
{
"message": "Missing data for required field.",
"error_type": "INVALID_PAYLOAD_SCHEMA_ERROR",
"level": "error",
"extra": {
"invalid": ["configuration_method"],
"issue_codes": [
{
"code": 1020,
"message": "Issue 1020 - The submitted payload has the incorrect schema.",
}
],
},
},
{
"message": "Missing data for required field.",
"error_type": "INVALID_PAYLOAD_SCHEMA_ERROR",
"level": "error",
"extra": {
"invalid": ["engine"],
"issue_codes": [
{
"code": 1020,
"message": "Issue 1020 - The submitted payload has the incorrect schema.",
}
],
},
},
]
}

def test_validate_parameters_missing_fields(self):
self.login(username="admin")
Expand Down

0 comments on commit 54b5ad5

Please # to comment.