55from flask import Flask
66from apispec import APISpec
77from 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
1112from flask .views import MethodView
1213from 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
213219def 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