Skip to content

Commit ea2803a

Browse files
committed
add event init error tests
1 parent 2a8aa9d commit ea2803a

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

tests/test_event.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def test_get_overlapping_events(
346346
end=Timestamp("2024-01-02 00:00:00"),
347347
)
348348
),
349-
id="valid begin",
349+
id="valid_begin",
350350
),
351351
pytest.param(
352352
Event(
@@ -361,7 +361,7 @@ def test_get_overlapping_events(
361361
end=Timestamp("2024-01-02 12:00:00"),
362362
)
363363
),
364-
id="valid end",
364+
id="valid_end",
365365
),
366366
pytest.param(
367367
Event(
@@ -371,7 +371,7 @@ def test_get_overlapping_events(
371371
Timestamp("2024-01-03 00:00:00"),
372372
None,
373373
pytest.raises(ValueError, match="`end`.*must be greater than `begin`.*"),
374-
id="invalid begin > end",
374+
id="invalid_begin_after_end",
375375
),
376376
pytest.param(
377377
Event(
@@ -381,7 +381,7 @@ def test_get_overlapping_events(
381381
None,
382382
Timestamp("2023-12-31 23:59:59"),
383383
pytest.raises(ValueError, match="`end`.*must be greater than `begin`.*"),
384-
id="invalid end < begin",
384+
id="invalid_end_before_begin",
385385
),
386386
pytest.param(
387387
Event(
@@ -391,7 +391,7 @@ def test_get_overlapping_events(
391391
Timestamp("2024-01-01 01:00:00"),
392392
None,
393393
pytest.raises(ValueError, match="`end`.*must be greater than `begin`.*"),
394-
id="begin and end equals",
394+
id="begin_equals_end",
395395
),
396396
],
397397
)
@@ -411,4 +411,24 @@ def update_event(
411411
return cool_event
412412

413413
with expected as e:
414-
assert update_event(event, updated_begin, updated_end) == e
414+
assert update_event(event, updated_begin, updated_end) == e
415+
416+
417+
@pytest.mark.parametrize(
418+
("begin", "end"),
419+
[
420+
pytest.param(
421+
Timestamp("2024-01-02 00:00:00"),
422+
Timestamp("2024-01-01 00:00:00"),
423+
id="begin_after_end",
424+
),
425+
pytest.param(
426+
Timestamp("2024-01-01 00:00:00"),
427+
Timestamp("2024-01-01 00:00:00"),
428+
id="begin_equals_end",
429+
),
430+
],
431+
)
432+
def test_event_errors(begin: Timestamp, end: Timestamp) -> None:
433+
with pytest.raises(ValueError, match="`end`.*must be greater than `begin`.*") as e:
434+
assert Event(begin=begin, end=end) == e

0 commit comments

Comments
 (0)