44from temp_client import poll_task
55import time
66import labthings_fastapi as lt
7+ from labthings_fastapi .actions import ACTION_INVOCATIONS_PATH
78
89
910class TestThing (lt .Thing ):
@@ -31,7 +32,7 @@ def run(payload=None):
3132 return run
3233
3334
34- def test_expiry ():
35+ def test_action_expires ():
3536 with TestClient (server .app ) as client :
3637 before_value = client .get ("/thing/counter" ).json ()
3738 r = client .post ("/thing/increment_counter" )
@@ -42,5 +43,17 @@ def test_expiry():
4243 after_value = client .get ("/thing/counter" ).json ()
4344 assert after_value == before_value + 2
4445 invocation ["status" ] = "running" # Force an extra poll
46+ # When the second action runs, the first one should expire
47+ # so polling it again should give a 404.
4548 with pytest .raises (httpx .HTTPStatusError ):
4649 poll_task (client , invocation )
50+
51+
52+ def test_actions_list ():
53+ with TestClient (server .app ) as client :
54+ r = client .post ("/thing/increment_counter" )
55+ invocation = poll_task (client , r .json ())
56+ r2 = client .get (ACTION_INVOCATIONS_PATH )
57+ r2 .raise_for_status ()
58+ invocations = r2 .json ()
59+ assert invocations == [invocation ]
0 commit comments