chore: update development dependencies and improve test coverage
Some checks failed
CI / lint-and-test (push) Failing after 11s
Some checks failed
CI / lint-and-test (push) Failing after 11s
- Upgraded `pytest-asyncio` to version 1.0 to ensure compatibility with the latest features and improvements. - Increased the coverage threshold in pytest configuration to 80%, enhancing the quality assurance process. - Added a new `conftest.py` file to manage shared fixtures and improve test organization. - Introduced multiple new test files to cover various components, ensuring comprehensive test coverage across the application. - Updated the `.coverage` file to reflect the latest coverage metrics.
This commit is contained in:
47
tests/test_import_service.py
Normal file
47
tests/test_import_service.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""Tests for duty_teller.services.import_service (_consecutive_date_ranges)."""
|
||||
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
|
||||
from duty_teller.services.import_service import _consecutive_date_ranges
|
||||
|
||||
|
||||
class TestConsecutiveDateRanges:
|
||||
"""Unit tests for _consecutive_date_ranges."""
|
||||
|
||||
def test_empty_returns_empty(self):
|
||||
assert _consecutive_date_ranges([]) == []
|
||||
|
||||
def test_single_day_one_range(self):
|
||||
d = date(2025, 2, 10)
|
||||
assert _consecutive_date_ranges([d]) == [(d, d)]
|
||||
|
||||
def test_consecutive_days_one_range(self):
|
||||
dates = [date(2025, 1, 10), date(2025, 1, 11), date(2025, 1, 12)]
|
||||
assert _consecutive_date_ranges(dates) == [
|
||||
(date(2025, 1, 10), date(2025, 1, 12)),
|
||||
]
|
||||
|
||||
def test_two_ranges_with_gap(self):
|
||||
dates = [
|
||||
date(2025, 1, 5),
|
||||
date(2025, 1, 6),
|
||||
date(2025, 1, 10),
|
||||
date(2025, 1, 11),
|
||||
]
|
||||
assert _consecutive_date_ranges(dates) == [
|
||||
(date(2025, 1, 5), date(2025, 1, 6)),
|
||||
(date(2025, 1, 10), date(2025, 1, 11)),
|
||||
]
|
||||
|
||||
def test_unsorted_with_duplicates_normalized(self):
|
||||
dates = [
|
||||
date(2025, 1, 12),
|
||||
date(2025, 1, 10),
|
||||
date(2025, 1, 11),
|
||||
date(2025, 1, 10),
|
||||
]
|
||||
assert _consecutive_date_ranges(dates) == [
|
||||
(date(2025, 1, 10), date(2025, 1, 12)),
|
||||
]
|
||||
Reference in New Issue
Block a user