Extend shift reporting and downtime analytics
This commit is contained in:
1 parent
41a5ae7a63
commit
6e8eb6f50f
74 files changed
+5397
-238
No files matched your search
@@ -108,6 +108,39 @@ def test_exact_parameterized_workplace_and_half_open_window(db):
|
||||
assert "[Rückmeldemenge] >" not in sql
|
||||
|
||||
|
||||
@pytest.mark.parametrize("timezone_name,expected_utc_hour", [
|
||||
("Europe/Berlin", 6), ("Asia/Kuala_Lumpur", 0),
|
||||
])
|
||||
def test_explicit_site_timezone_interprets_naive_sql_rows(
|
||||
db, timezone_name, expected_utc_hour,
|
||||
):
|
||||
timezone = ZoneInfo(timezone_name)
|
||||
start = datetime(2026, 10, 19, 6, tzinfo=timezone)
|
||||
end = datetime(2026, 10, 19, 14, tzinfo=timezone)
|
||||
local_row = datetime(2026, 10, 19, 8, 20)
|
||||
db[2].fetchall.return_value = [(*ROW[:2], local_row, *ROW[3:])]
|
||||
confirmation = read(start=start.astimezone(UTC), end=end.astimezone(UTC),
|
||||
timezone=timezone)[0]
|
||||
assert db[2].execute.call_args.args[1] == (
|
||||
"BENTO 1", datetime(2026, 10, 19, 6), datetime(2026, 10, 19, 14),
|
||||
)
|
||||
assert confirmation.timestamp == local_row.replace(tzinfo=timezone)
|
||||
assert confirmation.timestamp.tzinfo is timezone
|
||||
assert confirmation.timestamp.astimezone(UTC).hour == expected_utc_hour
|
||||
|
||||
|
||||
def test_malaysia_evening_confirmation_remains_local_evening(db):
|
||||
malaysia = ZoneInfo("Asia/Kuala_Lumpur")
|
||||
local_row = datetime(2026, 10, 19, 18)
|
||||
db[2].fetchall.return_value = [(*ROW[:2], local_row, *ROW[3:])]
|
||||
confirmation = read(
|
||||
start=datetime(2026, 10, 19, 14, tzinfo=malaysia),
|
||||
end=datetime(2026, 10, 19, 22, tzinfo=malaysia), timezone=malaysia,
|
||||
)[0]
|
||||
assert confirmation.timestamp.hour == 18
|
||||
assert confirmation.timestamp.astimezone(UTC) == datetime(2026, 10, 19, 10, tzinfo=UTC)
|
||||
|
||||
|
||||
def test_half_open_boundaries_with_query_simulation(db):
|
||||
rows = [
|
||||
tuple([*ROW[:2], timestamp, *ROW[3:]])
|
||||
|
||||
Reference in new issue
Block a user