Skip to content

Commit

Permalink
Move sds_schema_version validation into separate function and update …
Browse files Browse the repository at this point in the history
…test structure
  • Loading branch information
VirajP1002 committed Nov 14, 2024
1 parent be808f2 commit 88d9781
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/utilities/supplementary_data_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ def validate_dataset_and_survey_id( # pylint: disable=unused-argument
"Supplementary data did not return the specified Survey ID"
)

if (self.context["sds_schema_version"]) and (
@validates_schema()
def validate_sds_schema_version( # pylint: disable=unused-argument
self, payload: Mapping, **kwargs: Any
) -> None:
if payload:
if self.context["sds_schema_version"] and (
payload["data"]["schema_version"] != self.context["sds_schema_version"]
):
raise ValidationError(
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/session/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,15 @@ def test_login_with_sds_schema_version_valid(
self, mock_get, mock_validate, mock_set
):

# Given
schema_to_launch = "test_supplementary_data_with_sds_schema_version"

# When
self.launchSupplementaryDataSurvey(
schema_name="test_supplementary_data_with_sds_schema_version",
schema_name=schema_to_launch,
sds_dataset_id="203b2f9d-c500-8175-98db-86ffcfdccfa3",
)

# Then
mock_get.assert_called_once()
mock_validate.assert_called_once()
Expand Down

0 comments on commit 88d9781

Please sign in to comment.