-
Notifications
You must be signed in to change notification settings - Fork 546
Expand file tree
/
Copy pathtest_runtime_state.py
More file actions
56 lines (35 loc) · 1.13 KB
/
Copy pathtest_runtime_state.py
File metadata and controls
56 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from feapder.core.runtime_state import RuntimeState
def test_runtime_state_starts_idle_and_running():
state = RuntimeState()
assert state.is_idle is True
assert state.is_stop_requested is False
assert state.busy_count == 0
def test_runtime_state_tracks_busy_count():
state = RuntimeState()
state.mark_busy()
state.mark_busy()
assert state.is_idle is False
assert state.busy_count == 2
state.mark_idle()
state.mark_idle()
assert state.is_idle is True
assert state.busy_count == 0
def test_runtime_state_does_not_go_negative():
state = RuntimeState()
state.mark_idle()
assert state.busy_count == 0
assert state.is_idle is True
def test_runtime_state_busy_context_resets_on_exception():
state = RuntimeState()
try:
with state.busy():
assert state.is_idle is False
raise RuntimeError("boom")
except RuntimeError:
pass
assert state.is_idle is True
def test_runtime_state_stop_request_is_sticky():
state = RuntimeState()
state.request_stop()
state.request_stop()
assert state.is_stop_requested is True