5
5
from flask import Flask
6
6
from apispec import APISpec
7
7
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
10
11
11
12
from flask .views import MethodView
12
13
from labthings .views import View
@@ -21,11 +22,16 @@ def validate_thing_description(thing_description, app_ctx, schemas_path):
21
22
schema = json .load (open (os .path .join (schemas_path , "w3c_td_schema.json" ), "r" ))
22
23
jsonschema .Draft7Validator .check_schema (schema )
23
24
25
+ # Build a TD dictionary
24
26
with app_ctx .test_request_context ():
25
- td_json = thing_description .to_dict ()
26
- assert td_json
27
+ td_dict = thing_description .to_dict ()
27
28
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 )
29
35
30
36
31
37
@pytest .fixture
@@ -211,7 +217,7 @@ def app(request):
211
217
212
218
@pytest .fixture
213
219
def thing (app ):
214
- thing = LabThing (app )
220
+ thing = LabThing (app , external_links = False )
215
221
with app .app_context ():
216
222
return thing
217
223
0 commit comments