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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
import pytest
from referencing import Registry
from referencing._core import Resolver
from referencing.jsonschema import DRAFT202012
from jsonschema_path.accessors import SchemaAccessor
from jsonschema_path.handlers import default_handlers
from jsonschema_path.paths import SPEC_SEPARATOR
from jsonschema_path.retrievers import SchemaRetriever
@pytest.fixture
def assert_ra():
def func(
sa,
schema,
base_uri="",
handlers=default_handlers,
specification=DRAFT202012,
):
assert sa.lookup == schema
resolver = sa.resolver
assert type(resolver) is Resolver
assert resolver._base_uri == base_uri
registry = resolver._registry
assert type(registry) is Registry
assert type(registry._retrieve) is SchemaRetriever
assert registry._retrieve.handlers == handlers
assert registry._retrieve.specification == specification
return func
@pytest.fixture
def assert_sa():
def func(
sa,
schema,
base_uri="",
handlers=default_handlers,
specification=DRAFT202012,
):
assert type(sa) is SchemaAccessor
assert sa.lookup == schema
resolver = sa.resolver
assert type(resolver) is Resolver
assert resolver._base_uri == base_uri
registry = resolver._registry
assert type(registry) is Registry
assert type(registry._retrieve) is SchemaRetriever
assert registry._retrieve.handlers == handlers
assert registry._retrieve.specification == specification
return func
@pytest.fixture
def assert_sp(assert_sa):
def func(
sp,
schema,
separator=SPEC_SEPARATOR,
base_uri="",
handlers=default_handlers,
specification=DRAFT202012,
):
assert sp.separator == separator
assert sp.parts == []
assert_sa(
sp.accessor,
schema,
base_uri=base_uri,
handlers=handlers,
specification=specification,
)
return func
|