Skip to content

Commit 59c8fe0

Browse files
committed
Add a docstring to the new test and delete redundant function
1 parent b21c7f1 commit 59c8fe0

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

tests/test_action_manager.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ def increment_counter(self):
2323
server.add_thing(thing, "/thing")
2424

2525

26-
def action_partial(client: TestClient, url: str):
27-
def run(payload=None):
28-
r = client.post(url, json=payload)
29-
assert r.status_code in (200, 201)
30-
return poll_task(client, r.json())
26+
def test_action_expires():
27+
"""Check the action is removed from the server
3128
32-
return run
29+
We've set the retention period to be very short, so the action
30+
should not be retrievable after some time has elapsed.
3331
32+
This test checks that actions do indeed get removed.
3433
35-
def test_action_expires():
34+
Note that the code that expires actions runs whenever a new
35+
action is started. That's why we need to invoke the action twice:
36+
the second invocation runs the code that deletes the first one.
37+
This behaviour might change in the future, making the second run
38+
unnecessary.
39+
"""
3640
with TestClient(server.app) as client:
3741
before_value = client.get("/thing/counter").json()
3842
r = client.post("/thing/increment_counter")
@@ -50,6 +54,13 @@ def test_action_expires():
5054

5155

5256
def test_actions_list():
57+
"""Check that the /action_invocations/ path works.
58+
59+
The /action_invocations/ path should return a list of invocation
60+
objects (a representation of each action that's been run recently).
61+
62+
It's implemented in `ActionManager.list_all_invocations`.
63+
"""
5364
with TestClient(server.app) as client:
5465
r = client.post("/thing/increment_counter")
5566
invocation = poll_task(client, r.json())

0 commit comments

Comments
 (0)