Skip to content

Commit d039874

Browse files
author
Joel Collins
committed
Added tests for LabThing view builders
1 parent 096eb99 commit d039874

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

tests/test_labthing.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,24 @@ def test_version(thing):
240240
thing.version = "x.x.x"
241241
assert thing.version == "x.x.x"
242242
assert thing.spec.version == "x.x.x"
243+
244+
245+
def test_build_property(thing):
246+
obj = type("obj", (object,), {"property_name": "propertyValue"})
247+
248+
thing.build_property(obj, "property_name")
249+
# -1 index for last view added
250+
# 1 index for URL tuple
251+
assert "/properties/type/property_name" in thing.views[-1][1]
252+
253+
254+
def test_build_action(thing):
255+
def f():
256+
return "response"
257+
258+
obj = type("obj", (object,), {"f": f})
259+
260+
thing.build_action(obj, "f")
261+
# -1 index for last view added
262+
# 1 index for URL tuple
263+
assert "/actions/type/f" in thing.views[-1][1]

tests/test_views_builder.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
def test_property_of_no_schema(app, client):
1010
obj = type("obj", (object,), {"property_name": "propertyValue"})
1111

12-
# GeneratedClass = builder.property_of(obj, "property_name", schema=fields.String())
1312
GeneratedClass = builder.property_of(obj, "property_name", schema=fields.String())
1413
app.add_url_rule("/", view_func=GeneratedClass.as_view("index"))
1514

@@ -22,7 +21,6 @@ def test_property_of_no_schema(app, client):
2221
def test_property_of_with_schema(app, client):
2322
obj = type("obj", (object,), {"property_name": "propertyValue"})
2423

25-
# GeneratedClass = builder.property_of(obj, "property_name", schema=fields.String())
2624
GeneratedClass = builder.property_of(obj, "property_name", schema=fields.String())
2725
app.add_url_rule("/", view_func=GeneratedClass.as_view("index"))
2826

0 commit comments

Comments
 (0)