Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions tests/test_action_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@
from labthings_fastapi.actions import ACTION_INVOCATIONS_PATH


class TestThing(lt.Thing):
class CounterThing(lt.Thing):
@lt.thing_action(retention_time=0.01)
def increment_counter(self):
"""Increment the counter"""
"""Increment the counter."""
self.counter += 1

@lt.thing_action(retention_time=1)
def increment_counter_longlife(self):
"""Increment the counter.

This copy of the action won't expire as quickly.
"""
self.counter += 1

counter: int = lt.property(default=0, readonly=True)
"A pointless counter"


thing = TestThing()
thing = CounterThing()
server = lt.ThingServer()
server.add_thing(thing, "/thing")

Expand Down Expand Up @@ -61,7 +69,7 @@ def test_actions_list():
It's implemented in `ActionManager.list_all_invocations`.
"""
with TestClient(server.app) as client:
r = client.post("/thing/increment_counter")
r = client.post("/thing/increment_counter_longlife")
invocation = poll_task(client, r.json())
r2 = client.get(ACTION_INVOCATIONS_PATH)
r2.raise_for_status()
Expand Down