-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathtest_poll.py
More file actions
112 lines (82 loc) · 3.28 KB
/
Copy pathtest_poll.py
File metadata and controls
112 lines (82 loc) · 3.28 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
"""Tests for poll decision logic."""
import tapmap.state.poll as poll
def test_clear_cache_from_menu() -> None:
"""Return clear_cache when clear cache menu item is clicked."""
decision = poll.decide_poll_action(
trigger="menu_clear_cache",
key_action=None,
has_polled=True,
)
assert decision.action == poll.ACTION_CLEAR_CACHE
def test_clear_cache_from_keyboard_action() -> None:
"""Return clear_cache when keyboard action requests cache clear."""
decision = poll.decide_poll_action(
trigger="key_action",
key_action={"action": "menu_clear_cache"},
has_polled=True,
)
assert decision.action == poll.ACTION_CLEAR_CACHE
def test_normal_poll_on_tick_model_trigger() -> None:
"""Return normal_poll when the model timer ticks."""
decision = poll.decide_poll_action(
trigger="tick_model",
key_action=None,
has_polled=True,
)
assert decision.action == poll.ACTION_NORMAL_POLL
def test_normal_poll_before_first_poll_regardless_of_trigger() -> None:
"""Return normal_poll for any trigger until the first poll has completed."""
decision = poll.decide_poll_action(
trigger="key_action",
key_action=None,
has_polled=False,
)
assert decision.action == poll.ACTION_NORMAL_POLL
def test_zoom_connections_from_keyboard_action() -> None:
"""Return zoom_connections when the zoom keyboard action fires."""
decision = poll.decide_poll_action(
trigger="key_action",
key_action={"action": "zoom_connections"},
has_polled=True,
)
assert decision.action == poll.ACTION_ZOOM_CONNECTIONS
def test_rebuild_view_from_keyboard_action() -> None:
"""Return rebuild_view when the technical-details keyboard action fires."""
decision = poll.decide_poll_action(
trigger="key_action",
key_action={"action": "menu_technical_details"},
has_polled=True,
)
assert decision.action == poll.ACTION_REBUILD_VIEW
def test_none_when_export_cache_menu_is_clicked() -> None:
"""Return none for a trigger unrelated to the runtime model."""
decision = poll.decide_poll_action(
trigger="menu_export_cache",
key_action=None,
has_polled=True,
)
assert decision.action == poll.ACTION_NONE
def test_none_when_geodb_management_keyboard_action_fires() -> None:
"""Return none when a keyboard action opens GeoDB management."""
decision = poll.decide_poll_action(
trigger="key_action",
key_action={"action": "menu_geodb_management"},
has_polled=True,
)
assert decision.action == poll.ACTION_NONE
def test_none_when_export_cache_keyboard_action_fires() -> None:
"""Return none when a keyboard action requests cache export."""
decision = poll.decide_poll_action(
trigger="key_action",
key_action={"action": "menu_export_cache"},
has_polled=True,
)
assert decision.action == poll.ACTION_NONE
def test_none_when_keyboard_action_is_irrelevant() -> None:
"""Return none when the keyboard action doesn't match any known action."""
decision = poll.decide_poll_action(
trigger="key_action",
key_action={"action": "something_else"},
has_polled=True,
)
assert decision.action == poll.ACTION_NONE