From acb1927a7c19d0db1c94fc64eb6245a8dba6ff81 Mon Sep 17 00:00:00 2001 From: Cole French <16979554+ColeFrench@users.noreply.github.com> Date: Tue, 13 Aug 2024 17:43:53 -0400 Subject: [PATCH] Fix first day of year edge case --- tests/test_dashboards.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_dashboards.py b/tests/test_dashboards.py index deeadb0..15e445c 100644 --- a/tests/test_dashboards.py +++ b/tests/test_dashboards.py @@ -371,7 +371,12 @@ def test_dashboard_filter_processing(connection, raw_filter_dict, dt): ) .end_of("day") .strftime(date_format), - "year to date": pendulum.now("UTC").subtract(days=1).end_of("day").strftime(date_format), + "year to date": pendulum.now("UTC") + .subtract( + days=1 if pendulum.now("UTC").date() != pendulum.now("UTC").start_of("year").date() else 0 + ) + .end_of("day") + .strftime(date_format), "last week to date": pendulum.now("UTC") .subtract(weeks=1) .start_of("week") @@ -405,7 +410,11 @@ def test_dashboard_filter_processing(connection, raw_filter_dict, dt): "1 year ago to date": pendulum.now("UTC") .subtract(years=1) .start_of("year") - .add(days=(pendulum.now("UTC") - pendulum.now("UTC").start_of("year")).days - 1) + .add( + days=(pendulum.now("UTC") - pendulum.now("UTC").start_of("year")).days - 1 + if pendulum.now("UTC").date() != pendulum.now("UTC").start_of("year").date() + else 0 + ) .end_of("day") .strftime(date_format), "1 year ago for 3 months": pendulum.now("UTC")