1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
from unittest.mock import Mock
from jsonschema_path.accessors import SchemaAccessor
class TestSchemaAccessorOpen:
def test_dereferences_once(self):
retrieve = Mock(return_value={"value": "tested"})
accessor = SchemaAccessor.from_schema(
{
"one": {
"$ref": "x://testref",
},
"two": {
"$ref": "x://testref",
},
},
handlers={"x": retrieve},
)
with accessor.open(["one", "value"]) as opened:
assert opened == "tested"
with accessor.open(["two", "value"]) as opened:
assert opened == "tested"
retrieve.assert_called_once_with("x://testref")
|