Skip to content

Commit

Permalink
Fix report's multi truncate test
Browse files Browse the repository at this point in the history
A previous fix for leap days broke the test for non leap years.
  • Loading branch information
marcospri committed Jan 2, 2025
1 parent 6ddcd88 commit 0773960
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime, timedelta
from datetime import datetime

import importlib_resources
import pytest
Expand All @@ -9,8 +9,8 @@


class TestDateFunctions:
ONE_YEAR_AGO = (datetime.now() - timedelta(days=365)).date()
TWO_YEARS_AGO = (datetime.now() - timedelta(days=365 * 2)).date()
ONE_YEAR_AGO = datetime.now().replace(year=datetime.now().year - 1).date()
TWO_YEARS_AGO = datetime.now().replace(year=datetime.now().year - 2).date()

@pytest.mark.usefixtures("with_date_functions")
@pytest.mark.parametrize(
Expand All @@ -20,8 +20,8 @@ class TestDateFunctions:
# Technically this test could fail if you run this exactly at midnight
("trailing_year", "NOW() - INTERVAL '1 second'", ONE_YEAR_AGO),
("trailing_year", "NOW() - INTERVAL '1 day'", ONE_YEAR_AGO),
("trailing_year", "NOW() - INTERVAL '365 days'", TWO_YEARS_AGO),
("trailing_year", "NOW() - INTERVAL '366 days'", TWO_YEARS_AGO),
("trailing_year", "NOW() - INTERVAL '1 year'", TWO_YEARS_AGO),
("trailing_year", "NOW() - INTERVAL '1 year 1 day'", TWO_YEARS_AGO),
),
)
def test_multi_truncate(self, db_session, timescale, value, expected):
Expand Down

0 comments on commit 0773960

Please sign in to comment.