Skip to content

Commit 5cc20c2

Browse files
committed
test_model: add types
1 parent a610d24 commit 5cc20c2

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

safeeyes/tests/test_model.py

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,28 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import pytest
1920
import random
21+
import typing
2022
from safeeyes import model
2123

2224

2325
class TestBreak:
24-
def test_break_short(self):
26+
def test_break_short(self) -> None:
2527
b = model.Break(model.BreakType.SHORT_BREAK, "test break", 15, 15, None, None)
2628

2729
assert b.is_short_break()
2830
assert not b.is_long_break()
2931

30-
def test_break_long(self):
32+
def test_break_long(self) -> None:
3133
b = model.Break(model.BreakType.LONG_BREAK, "long break", 75, 60, None, None)
3234

3335
assert not b.is_short_break()
3436
assert b.is_long_break()
3537

3638

3739
class TestBreakQueue:
38-
def test_create_empty(self):
40+
def test_create_empty(self) -> None:
3941
config = {
4042
"short_breaks": [],
4143
"long_breaks": [],
@@ -46,7 +48,7 @@ def test_create_empty(self):
4648
"random_order": False,
4749
}
4850

49-
context = {}
51+
context: dict[str, typing.Any] = {}
5052

5153
bq = model.BreakQueue(config, context)
5254

@@ -56,7 +58,9 @@ def test_create_empty(self):
5658
assert bq.next() is None
5759
assert bq.get_break() is None
5860

59-
def get_bq_only_short(self, monkeypatch, random_seed=None):
61+
def get_bq_only_short(
62+
self, monkeypatch: pytest.MonkeyPatch, random_seed: typing.Optional[int] = None
63+
) -> model.BreakQueue:
6064
if random_seed is not None:
6165
random.seed(random_seed)
6266

@@ -78,13 +82,15 @@ def get_bq_only_short(self, monkeypatch, random_seed=None):
7882
"random_order": random_seed is not None,
7983
}
8084

81-
context = {
85+
context: dict[str, typing.Any] = {
8286
"session": {},
8387
}
8488

8589
return model.BreakQueue(config, context)
8690

87-
def get_bq_only_long(self, monkeypatch, random_seed=None):
91+
def get_bq_only_long(
92+
self, monkeypatch: pytest.MonkeyPatch, random_seed: typing.Optional[int] = None
93+
) -> model.BreakQueue:
8894
if random_seed is not None:
8995
random.seed(random_seed)
9096

@@ -106,13 +112,15 @@ def get_bq_only_long(self, monkeypatch, random_seed=None):
106112
"random_order": random_seed is not None,
107113
}
108114

109-
context = {
115+
context: dict[str, typing.Any] = {
110116
"session": {},
111117
}
112118

113119
return model.BreakQueue(config, context)
114120

115-
def get_bq_full(self, monkeypatch, random_seed=None):
121+
def get_bq_full(
122+
self, monkeypatch: pytest.MonkeyPatch, random_seed: typing.Optional[int] = None
123+
) -> model.BreakQueue:
116124
if random_seed is not None:
117125
random.seed(random_seed)
118126

@@ -139,20 +147,22 @@ def get_bq_full(self, monkeypatch, random_seed=None):
139147
"random_order": random_seed is not None,
140148
}
141149

142-
context = {
150+
context: dict[str, typing.Any] = {
143151
"session": {},
144152
}
145153

146154
return model.BreakQueue(config, context)
147155

148-
def test_create_only_short(self, monkeypatch):
156+
def test_create_only_short(self, monkeypatch: pytest.MonkeyPatch) -> None:
149157
bq = self.get_bq_only_short(monkeypatch)
150158

151159
assert not bq.is_empty()
152160
assert not bq.is_empty(model.BreakType.SHORT_BREAK)
153161
assert bq.is_empty(model.BreakType.LONG_BREAK)
154162

155-
def test_only_short_repeat_get_break_no_change(self, monkeypatch):
163+
def test_only_short_repeat_get_break_no_change(
164+
self, monkeypatch: pytest.MonkeyPatch
165+
) -> None:
156166
bq = self.get_bq_only_short(monkeypatch)
157167

158168
next = bq.get_break()
@@ -163,7 +173,7 @@ def test_only_short_repeat_get_break_no_change(self, monkeypatch):
163173

164174
assert not bq.is_long_break()
165175

166-
def test_only_short_next_break(self, monkeypatch):
176+
def test_only_short_next_break(self, monkeypatch: pytest.MonkeyPatch) -> None:
167177
bq = self.get_bq_only_short(monkeypatch)
168178

169179
next = bq.get_break()
@@ -178,7 +188,9 @@ def test_only_short_next_break(self, monkeypatch):
178188
assert bq.next().name == "translated!: break 2"
179189
assert bq.next().name == "translated!: break 3"
180190

181-
def test_only_short_next_break_random(self, monkeypatch):
191+
def test_only_short_next_break_random(
192+
self, monkeypatch: pytest.MonkeyPatch
193+
) -> None:
182194
random_seed = 5
183195
bq = self.get_bq_only_short(monkeypatch, random_seed)
184196

@@ -190,14 +202,16 @@ def test_only_short_next_break_random(self, monkeypatch):
190202
assert bq.next().name == "translated!: break 3"
191203
assert bq.next().name == "translated!: break 1"
192204

193-
def test_create_only_long(self, monkeypatch):
205+
def test_create_only_long(self, monkeypatch: pytest.MonkeyPatch) -> None:
194206
bq = self.get_bq_only_long(monkeypatch)
195207

196208
assert not bq.is_empty()
197209
assert not bq.is_empty(model.BreakType.LONG_BREAK)
198210
assert bq.is_empty(model.BreakType.SHORT_BREAK)
199211

200-
def test_only_long_repeat_get_break_no_change(self, monkeypatch):
212+
def test_only_long_repeat_get_break_no_change(
213+
self, monkeypatch: pytest.MonkeyPatch
214+
) -> None:
201215
bq = self.get_bq_only_long(monkeypatch)
202216

203217
next = bq.get_break()
@@ -208,7 +222,7 @@ def test_only_long_repeat_get_break_no_change(self, monkeypatch):
208222

209223
assert bq.is_long_break()
210224

211-
def test_only_long_next_break(self, monkeypatch):
225+
def test_only_long_next_break(self, monkeypatch: pytest.MonkeyPatch) -> None:
212226
bq = self.get_bq_only_long(monkeypatch)
213227

214228
next = bq.get_break()
@@ -223,7 +237,7 @@ def test_only_long_next_break(self, monkeypatch):
223237
assert bq.next().name == "translated!: long break 2"
224238
assert bq.next().name == "translated!: long break 3"
225239

226-
def test_only_long_next_break_random(self, monkeypatch):
240+
def test_only_long_next_break_random(self, monkeypatch: pytest.MonkeyPatch) -> None:
227241
random_seed = 5
228242
bq = self.get_bq_only_long(monkeypatch, random_seed)
229243

@@ -235,14 +249,16 @@ def test_only_long_next_break_random(self, monkeypatch):
235249
assert bq.next().name == "translated!: long break 3"
236250
assert bq.next().name == "translated!: long break 1"
237251

238-
def test_create_full(self, monkeypatch):
252+
def test_create_full(self, monkeypatch: pytest.MonkeyPatch) -> None:
239253
bq = self.get_bq_full(monkeypatch)
240254

241255
assert not bq.is_empty()
242256
assert not bq.is_empty(model.BreakType.LONG_BREAK)
243257
assert not bq.is_empty(model.BreakType.SHORT_BREAK)
244258

245-
def test_full_repeat_get_break_no_change(self, monkeypatch):
259+
def test_full_repeat_get_break_no_change(
260+
self, monkeypatch: pytest.MonkeyPatch
261+
) -> None:
246262
bq = self.get_bq_full(monkeypatch)
247263

248264
next = bq.get_break()
@@ -253,7 +269,7 @@ def test_full_repeat_get_break_no_change(self, monkeypatch):
253269

254270
assert not bq.is_long_break()
255271

256-
def test_full_next_break(self, monkeypatch):
272+
def test_full_next_break(self, monkeypatch: pytest.MonkeyPatch) -> None:
257273
bq = self.get_bq_full(monkeypatch)
258274

259275
next = bq.get_break()
@@ -297,7 +313,7 @@ def test_full_next_break(self, monkeypatch):
297313
assert bq.next().name == "translated!: break 4"
298314
assert bq.next().name == "translated!: long break 1"
299315

300-
def test_full_next_break_random(self, monkeypatch):
316+
def test_full_next_break_random(self, monkeypatch: pytest.MonkeyPatch) -> None:
301317
random_seed = 5
302318
bq = self.get_bq_full(monkeypatch, random_seed)
303319

0 commit comments

Comments
 (0)