Skip to content

Commit d802882

Browse files
committed
Added an assertion to actions
1 parent e34794f commit d802882

File tree

1 file changed

+6
-0
lines changed
  • labthings/server/spec

1 file changed

+6
-0
lines changed

labthings/server/spec/td.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ def property(self, rules: list, view: View):
212212
self.properties[key] = self.view_to_thing_property(rules, view)
213213

214214
def action(self, rules: list, view: View):
215+
"""Add a view representing an Action.
216+
217+
NB at present this will fail for any view that doesn't support POST
218+
requests.
219+
"""
220+
assert hasattr(view, "post"), "Thing actions must have a POST method!"
215221
endpoint = getattr(view, "endpoint") or getattr(rules[0], "endpoint")
216222
key = snake_to_camel(endpoint)
217223
self.actions[key] = self.view_to_thing_action(rules, view)

0 commit comments

Comments
 (0)