From 8f7d4bdf77b746d3cb52bc2c24718e2a8a3024b3 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Tue, 30 May 2023 13:37:15 +0300 Subject: [PATCH] Adapting tests for computedValues attribute. We are now removing all None values before comparison. --- arango/formatter.py | 28 ++++++++++++---------------- tests/conftest.py | 6 ++++++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/arango/formatter.py b/arango/formatter.py index ec06cbdf..44efc9aa 100644 --- a/arango/formatter.py +++ b/arango/formatter.py @@ -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"] diff --git a/tests/conftest.py b/tests/conftest.py index a708cc2b..cd670a96 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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("_"))