Skip to content

Commit 34ebb4c

Browse files
author
Joel Collins
committed
Handle ResourceURL class in TD validator
1 parent 0ef460d commit 34ebb4c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/conftest.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
from flask import Flask
66
from apispec import APISpec
77
from apispec.ext.marshmallow import MarshmallowPlugin
8-
from labthings.server.labthing import LabThing
9-
from labthings.actions.pool import Pool
8+
from labthings import LabThing
9+
from labthings.actions import Pool
10+
from labthings.json import encode_json
1011

1112
from flask.views import MethodView
1213
from labthings.views import View
@@ -21,11 +22,16 @@ def validate_thing_description(thing_description, app_ctx, schemas_path):
2122
schema = json.load(open(os.path.join(schemas_path, "w3c_td_schema.json"), "r"))
2223
jsonschema.Draft7Validator.check_schema(schema)
2324

25+
# Build a TD dictionary
2426
with app_ctx.test_request_context():
25-
td_json = thing_description.to_dict()
26-
assert td_json
27+
td_dict = thing_description.to_dict()
2728

28-
jsonschema.validate(instance=td_json, schema=schema)
29+
# Allow our LabThingsJSONEncoder to encode the RD
30+
td_json = encode_json(td_dict)
31+
# Decode the JSON back into a primitive dictionary
32+
td_json_dict = json.loads(td_json)
33+
# Validate
34+
jsonschema.validate(instance=td_json_dict, schema=schema)
2935

3036

3137
@pytest.fixture
@@ -211,7 +217,7 @@ def app(request):
211217

212218
@pytest.fixture
213219
def thing(app):
214-
thing = LabThing(app)
220+
thing = LabThing(app, external_links=False)
215221
with app.app_context():
216222
return thing
217223

0 commit comments

Comments
 (0)