Skip to content

Commit

Permalink
Added tests for LabThing view builders
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Collins committed Jul 20, 2020
1 parent 096eb99 commit d039874
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 21 additions & 0 deletions tests/test_labthing.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,24 @@ def test_version(thing):
thing.version = "x.x.x"
assert thing.version == "x.x.x"
assert thing.spec.version == "x.x.x"


def test_build_property(thing):
obj = type("obj", (object,), {"property_name": "propertyValue"})

thing.build_property(obj, "property_name")
# -1 index for last view added
# 1 index for URL tuple
assert "/properties/type/property_name" in thing.views[-1][1]


def test_build_action(thing):
def f():
return "response"

obj = type("obj", (object,), {"f": f})

thing.build_action(obj, "f")
# -1 index for last view added
# 1 index for URL tuple
assert "/actions/type/f" in thing.views[-1][1]
2 changes: 0 additions & 2 deletions tests/test_views_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
def test_property_of_no_schema(app, client):
obj = type("obj", (object,), {"property_name": "propertyValue"})

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

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

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

Expand Down

0 comments on commit d039874

Please sign in to comment.