From 25e969c6345828304ae86d60fc4d808cd9a0e42f Mon Sep 17 00:00:00 2001 From: Per Olav Svendsen Date: Wed, 27 Sep 2023 11:22:22 +0200 Subject: [PATCH] test that ALLOWED_CONTENTS is in synch with schema. --- tests/test_schema/test_schema_logic.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_schema/test_schema_logic.py b/tests/test_schema/test_schema_logic.py index 247190edd..4958297aa 100644 --- a/tests/test_schema/test_schema_logic.py +++ b/tests/test_schema/test_schema_logic.py @@ -6,6 +6,7 @@ import pytest +from fmu.dataio._definitions import ALLOWED_CONTENTS # pylint: disable=no-member @@ -399,3 +400,17 @@ def test_schema_logic_content_whitelist(schema_080, metadata_examples): example_surface["data"]["content"] = "not_valid_content" with pytest.raises(jsonschema.exceptions.ValidationError): jsonschema.validate(instance=example_surface, schema=schema_080) + + +def test_schema_content_synch_with_code(schema_080): + """Currently, the whitelist for content is maintained both in the schema + and in the code. This test asserts that list used in the code is in synch + with schema. Note! This is one-way, and will not fail if additional + elements are added to the schema only.""" + + schema_allowed = schema_080["definitions"]["data"]["properties"]["content"]["enum"] + for allowed_content in ALLOWED_CONTENTS: + if allowed_content not in schema_allowed: + raise ValueError( + f"content '{allowed_content}' allowed in code, but not schema." + )