@@ -167,97 +167,6 @@ def stop(self):
167
167
if handle :
168
168
handle .stop ()
169
169
170
- def test_create_empty (self ):
171
- context = {}
172
- config = {
173
- "short_breaks" : [],
174
- "long_breaks" : [],
175
- "short_break_interval" : 15 ,
176
- "long_break_interval" : 75 ,
177
- "long_break_duration" : 60 ,
178
- "short_break_duration" : 15 ,
179
- "random_order" : False ,
180
- "postpone_duration" : 5 ,
181
- }
182
- safe_eyes_core = core .SafeEyesCore (context )
183
- safe_eyes_core .initialize (config )
184
-
185
-
186
- def test_start_empty (self , sequential_threading ):
187
-
188
- context = {}
189
- config = {
190
- "short_breaks" : [],
191
- "long_breaks" : [],
192
- "short_break_interval" : 15 ,
193
- "long_break_interval" : 75 ,
194
- "long_break_duration" : 60 ,
195
- "short_break_duration" : 15 ,
196
- "random_order" : False ,
197
- "postpone_duration" : 5 ,
198
- }
199
- on_update_next_break = mock .Mock ()
200
- safe_eyes_core = core .SafeEyesCore (context )
201
- safe_eyes_core .on_update_next_break += mock
202
-
203
- safe_eyes_core .initialize (config )
204
-
205
- safe_eyes_core .start ()
206
- safe_eyes_core .stop ()
207
-
208
- on_update_next_break .assert_not_called ()
209
-
210
-
211
- def test_start (self , sequential_threading , time_machine ):
212
- context = {
213
- "session" : {},
214
- }
215
- config = {
216
- "short_breaks" : [
217
- {"name" : "break 1" },
218
- {"name" : "break 2" },
219
- {"name" : "break 3" },
220
- {"name" : "break 4" },
221
- ],
222
- "long_breaks" : [
223
- {"name" : "long break 1" },
224
- {"name" : "long break 2" },
225
- {"name" : "long break 3" },
226
- ],
227
- "short_break_interval" : 15 ,
228
- "long_break_interval" : 75 ,
229
- "long_break_duration" : 60 ,
230
- "short_break_duration" : 15 ,
231
- "random_order" : False ,
232
- "postpone_duration" : 5 ,
233
- }
234
- on_update_next_break = mock .Mock ()
235
- safe_eyes_core = core .SafeEyesCore (context )
236
- safe_eyes_core .on_update_next_break += on_update_next_break
237
-
238
- safe_eyes_core .initialize (config )
239
-
240
- sequential_threading_handle = sequential_threading (safe_eyes_core )
241
-
242
- safe_eyes_core .start ()
243
-
244
- # start __scheduler_job
245
- sequential_threading_handle .next ()
246
-
247
- assert context ['state' ] == model .State .WAITING
248
-
249
- on_update_next_break .assert_called_once ()
250
- assert isinstance (on_update_next_break .call_args [0 ][0 ], model .Break )
251
- assert on_update_next_break .call_args [0 ][0 ].name == "translated!: break 1"
252
- on_update_next_break .reset_mock ()
253
-
254
- # wait for end of __scheduler_job - we cannot stop while waiting on the condvar
255
- # this just moves us into waiting for __wait_until_prepare to start
256
- sequential_threading_handle .next ()
257
-
258
- safe_eyes_core .stop ()
259
- assert context ['state' ] == model .State .STOPPED
260
-
261
170
262
171
def run_next_break (
263
172
self ,
@@ -348,11 +257,104 @@ def run_next_break(
348
257
349
258
assert context ['state' ] == model .State .BREAK
350
259
260
+
351
261
def assert_datetime (self , string ):
352
262
if not string .endswith ("+00:00" ):
353
263
string += "+00:00"
354
264
assert datetime .datetime .now (datetime .timezone .utc ) == datetime .datetime .fromisoformat (string )
355
265
266
+
267
+ def test_create_empty (self ):
268
+ context = {}
269
+ config = {
270
+ "short_breaks" : [],
271
+ "long_breaks" : [],
272
+ "short_break_interval" : 15 ,
273
+ "long_break_interval" : 75 ,
274
+ "long_break_duration" : 60 ,
275
+ "short_break_duration" : 15 ,
276
+ "random_order" : False ,
277
+ "postpone_duration" : 5 ,
278
+ }
279
+ safe_eyes_core = core .SafeEyesCore (context )
280
+ safe_eyes_core .initialize (config )
281
+
282
+
283
+ def test_start_empty (self , sequential_threading ):
284
+ context = {}
285
+ config = {
286
+ "short_breaks" : [],
287
+ "long_breaks" : [],
288
+ "short_break_interval" : 15 ,
289
+ "long_break_interval" : 75 ,
290
+ "long_break_duration" : 60 ,
291
+ "short_break_duration" : 15 ,
292
+ "random_order" : False ,
293
+ "postpone_duration" : 5 ,
294
+ }
295
+ on_update_next_break = mock .Mock ()
296
+ safe_eyes_core = core .SafeEyesCore (context )
297
+ safe_eyes_core .on_update_next_break += mock
298
+
299
+ safe_eyes_core .initialize (config )
300
+
301
+ safe_eyes_core .start ()
302
+ safe_eyes_core .stop ()
303
+
304
+ on_update_next_break .assert_not_called ()
305
+
306
+
307
+ def test_start (self , sequential_threading , time_machine ):
308
+ context = {
309
+ "session" : {},
310
+ }
311
+ config = {
312
+ "short_breaks" : [
313
+ {"name" : "break 1" },
314
+ {"name" : "break 2" },
315
+ {"name" : "break 3" },
316
+ {"name" : "break 4" },
317
+ ],
318
+ "long_breaks" : [
319
+ {"name" : "long break 1" },
320
+ {"name" : "long break 2" },
321
+ {"name" : "long break 3" },
322
+ ],
323
+ "short_break_interval" : 15 ,
324
+ "long_break_interval" : 75 ,
325
+ "long_break_duration" : 60 ,
326
+ "short_break_duration" : 15 ,
327
+ "random_order" : False ,
328
+ "postpone_duration" : 5 ,
329
+ }
330
+ on_update_next_break = mock .Mock ()
331
+ safe_eyes_core = core .SafeEyesCore (context )
332
+ safe_eyes_core .on_update_next_break += on_update_next_break
333
+
334
+ safe_eyes_core .initialize (config )
335
+
336
+ sequential_threading_handle = sequential_threading (safe_eyes_core )
337
+
338
+ safe_eyes_core .start ()
339
+
340
+ # start __scheduler_job
341
+ sequential_threading_handle .next ()
342
+
343
+ assert context ['state' ] == model .State .WAITING
344
+
345
+ on_update_next_break .assert_called_once ()
346
+ assert isinstance (on_update_next_break .call_args [0 ][0 ], model .Break )
347
+ assert on_update_next_break .call_args [0 ][0 ].name == "translated!: break 1"
348
+ on_update_next_break .reset_mock ()
349
+
350
+ # wait for end of __scheduler_job - we cannot stop while waiting on the condvar
351
+ # this just moves us into waiting for __wait_until_prepare to start
352
+ sequential_threading_handle .next ()
353
+
354
+ safe_eyes_core .stop ()
355
+ assert context ['state' ] == model .State .STOPPED
356
+
357
+
356
358
def test_full_run_with_defaults (self , sequential_threading , time_machine ):
357
359
context = {
358
360
"session" : {},
0 commit comments