Files
duty-teller/tests/test_import_service.py
Nikolay Tatarinov e25eb7be2f
Some checks failed
CI / lint-and-test (push) Failing after 11s
chore: update development dependencies and improve test coverage
- 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.
2026-02-20 17:33:04 +03:00

48 lines
1.4 KiB
Python

"""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)),
]