Skip to content

Commit

Permalink
Adapting tests for computedValues attribute. We are now removing all …
Browse files Browse the repository at this point in the history
…None values before comparison.
  • Loading branch information
apetenchea committed May 30, 2023
1 parent 47a0047 commit 8f7d4bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
28 changes: 12 additions & 16 deletions arango/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,22 +217,18 @@ def format_collection(body: Json) -> Json:
result["schema"] = body["schema"]

# New in 3.10
if "computedValues" in body:
result["computedValues"] = (
[
{
"name": cv["name"],
"expression": cv["expression"],
"overwrite": cv["overwrite"],
"computedOn": cv["computedOn"],
"keepNull": cv["keepNull"],
"failOnWarning": cv["failOnWarning"],
}
for cv in body["computedValues"]
]
if body.get("computedValues") is not None
else None
)
if body.get("computedValues") is not None:
result["computedValues"] = [
{
"name": cv["name"],
"expression": cv["expression"],
"overwrite": cv["overwrite"],
"computedOn": cv["computedOn"],
"keepNull": cv["keepNull"],
"failOnWarning": cv["failOnWarning"],
}
for cv in body["computedValues"]
]
if "internalValidatorType" in body:
result["internal_validator_type"] = body["internalValidatorType"]

Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ def mock_verify_format(body, result):
body.pop("error", None)
body.pop("code", None)
result.pop("edge", None)

# Remove all None values
# Sometimes they are expected to be excluded from the body (see computedValues)
result = {k: v for k, v in result.items() if v is not None}
body = {k: v for k, v in body.items() if v is not None}

if len(body) != len(result):
before = sorted(body, key=lambda x: x.strip("_"))
after = sorted(result, key=lambda x: x.strip("_"))
Expand Down

0 comments on commit 8f7d4bd

Please sign in to comment.