Skip to content

Commit

Permalink
test that ALLOWED_CONTENTS is in synch with schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
perolavsvendsen committed Sep 27, 2023
1 parent a3867bb commit 25e969c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_schema/test_schema_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest

from fmu.dataio._definitions import ALLOWED_CONTENTS

# pylint: disable=no-member

Expand Down Expand Up @@ -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."
)

0 comments on commit 25e969c

Please sign in to comment.