Initial standalone memabra release
This commit is contained in:
30
tests/test_schemas.py
Normal file
30
tests/test_schemas.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import pytest
|
||||
|
||||
from memabra.schemas import SchemaRegistry, SchemaValidationError
|
||||
|
||||
|
||||
EXAMPLE_TRAJECTORY = "docs/examples/trajectory_success_memory.json"
|
||||
|
||||
|
||||
def test_schema_registry_validates_example_trajectory():
|
||||
registry = SchemaRegistry()
|
||||
with open(EXAMPLE_TRAJECTORY, "r", encoding="utf-8") as f:
|
||||
example = __import__("json").load(f)
|
||||
registry.validate_trajectory(example)
|
||||
|
||||
|
||||
def test_schema_registry_rejects_missing_required_keys():
|
||||
registry = SchemaRegistry()
|
||||
with pytest.raises(SchemaValidationError):
|
||||
registry.validate_trajectory({"trajectory_id": "oops"})
|
||||
|
||||
|
||||
def test_no_resource_warning_from_schema_validation():
|
||||
import warnings
|
||||
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always", ResourceWarning)
|
||||
test_schema_registry_validates_example_trajectory()
|
||||
|
||||
resource_warnings = [x for x in w if issubclass(x.category, ResourceWarning)]
|
||||
assert len(resource_warnings) == 0
|
||||
Reference in New Issue
Block a user