From d1762d2b9cfc2b5119caf12d62076181ce898ecf Mon Sep 17 00:00:00 2001 From: cortadocodes Date: Thu, 14 Nov 2024 13:11:29 +0000 Subject: [PATCH] TST: Test getting cached event schema validator skipci --- tests/cloud/events/test_validation.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/cloud/events/test_validation.py diff --git a/tests/cloud/events/test_validation.py b/tests/cloud/events/test_validation.py new file mode 100644 index 000000000..6cc3ef0e5 --- /dev/null +++ b/tests/cloud/events/test_validation.py @@ -0,0 +1,17 @@ +import unittest + +import jsonschema + +from octue.cloud.events.validation import _get_validator, cached_validator, SERVICE_COMMUNICATION_SCHEMA + + +class TestGetValidator(unittest.TestCase): + def test_cached_validator_returned_if_event_schema_is_official(self): + """Test that the cached validator is returned if the official event schema is provided.""" + self.assertEqual(_get_validator(schema=SERVICE_COMMUNICATION_SCHEMA), cached_validator.validate) + + def test_uncached_validator_returned_if_custom_event_schema_provided(self): + """Test that the uncached validator is returned if a custom event schema is provided.""" + validator = _get_validator(schema={}) + self.assertIs(validator.func, jsonschema.validate) + self.assertEqual(validator.keywords, {"schema": {}})