Skip to content

Commit

Permalink
TST: Test getting cached event schema validator
Browse files Browse the repository at this point in the history
skipci
  • Loading branch information
cortadocodes committed Nov 14, 2024
1 parent 2d3b352 commit d1762d2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/cloud/events/test_validation.py
Original file line number Diff line number Diff line change
@@ -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": {}})

0 comments on commit d1762d2

Please sign in to comment.