From ca873564bd0d5c05ff9701fdea8a4cf09079ac27 Mon Sep 17 00:00:00 2001 From: cortadocodes Date: Thu, 12 Dec 2024 11:24:23 +0000 Subject: [PATCH] TST: Test missing optional strands don't raise errors --- tests/test_manifest_strands.py | 5 +++++ tests/test_schema_strands.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/tests/test_manifest_strands.py b/tests/test_manifest_strands.py index ac0fd3d..3ee6f54 100644 --- a/tests/test_manifest_strands.py +++ b/tests/test_manifest_strands.py @@ -308,3 +308,8 @@ def test_error_raised_if_multiple_datasets_have_same_name(self): with self.assertRaises(KeyError): twine.validate_input_manifest(source=input_manifest) + + def test_missing_optional_manifest_does_not_raise_error(self): + """Test that not providing an optional strand doesn't result in a validation error.""" + twine = Twine(source={"output_manifest": {"datasets": {}, "optional": True}}) + twine.validate(output_manifest=None) diff --git a/tests/test_schema_strands.py b/tests/test_schema_strands.py index d60dece..44c8d40 100644 --- a/tests/test_schema_strands.py +++ b/tests/test_schema_strands.py @@ -111,6 +111,11 @@ def test_valid_with_extra_values(self): Twine(source=VALID_SCHEMA_TWINE).validate_configuration_values(source=configuration_valid_with_extra_field) + def test_missing_optional_values_do_not_raise_error(self): + """Test that not providing an optional strand doesn't result in a validation error.""" + twine = Twine(source={"configuration_values_schema": {"optional": True}}) + twine.validate(configuration_values=None) + if __name__ == "__main__": unittest.main()