Skip to content

Commit

Permalink
raises NotImplementedError for data/function backgrounds (RascalSoft…
Browse files Browse the repository at this point in the history
…ware#57)

* added error if attempt to use data or function models

* raises NotImplementedError for data/function backgrounds

* changed to field validator

* added return to field validator
  • Loading branch information
alexhroom authored Aug 5, 2024
1 parent d4fb0bb commit 619fd7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions RATapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ class Background(RATModel):
value_4: str = ""
value_5: str = ""

@field_validator("type")
@classmethod
def validate_unimplemented_backgrounds(cls, type: TypeOptions):
"""Raise an error if currently unsupported Data or Function backgrounds are used."""
# FIXME: once data/function backgrounds have been implemented,
# please remember to remove the @pytest.mark.skip decorators used to skip the tests:
# - tests/test_project.py::test_check_allowed_background_resolution_values_data
# - tests/test_project.py::test_check_allowed_background_resolution_values_on_data_list
if type == TypeOptions.Data:
raise NotImplementedError("Data backgrounds are not yet supported.")
if type == TypeOptions.Function:
raise NotImplementedError("Function backgrounds are not yet supported.")
return type


class Contrast(RATModel):
"""Groups together all of the components of the model."""
Expand Down
2 changes: 2 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ def test_check_allowed_background_resolution_values_constant(test_value: str) ->
)


@pytest.mark.skip("Data backgrounds not currently supported.")
@pytest.mark.parametrize(
"test_value",
[
Expand Down Expand Up @@ -999,6 +1000,7 @@ def test_check_allowed_background_resolution_values_not_on_constant_list(test_va
)


@pytest.mark.skip("Data backgrounds not currently supported.")
@pytest.mark.parametrize(
"test_value",
[
Expand Down

0 comments on commit 619fd7f

Please sign in to comment.