-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: Test getting cached event schema validator
skipci
- Loading branch information
1 parent
2d3b352
commit d1762d2
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": {}}) |