From 4081fa04e733e123218cab8065426b9106873c2f Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Mon, 25 Feb 2019 14:51:49 -0500 Subject: [PATCH] Use pendulum to traverse mock reporting dates Previously, subtracting 29 days could result in the same month listed twice (for example, subtracting 29 days from Nov 30, would result in two Novembers listed). --- atst/domain/csp/reports.py | 5 ++--- tests/routes/portfolios/test_portfolios_index.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/atst/domain/csp/reports.py b/atst/domain/csp/reports.py index 514b05c9..704ffa46 100644 --- a/atst/domain/csp/reports.py +++ b/atst/domain/csp/reports.py @@ -1,4 +1,3 @@ -import datetime from itertools import groupby from collections import OrderedDict import pendulum @@ -33,10 +32,10 @@ class MockApplication: def generate_sample_dates(_max=8): - current = datetime.datetime.today() + current = pendulum.now() sample_dates = [] for _i in range(_max): - current = current - datetime.timedelta(days=29) + current = current.subtract(months=1) sample_dates.append(current.strftime("%m/%Y")) reversed(sample_dates) diff --git a/tests/routes/portfolios/test_portfolios_index.py b/tests/routes/portfolios/test_portfolios_index.py index 39849480..49787575 100644 --- a/tests/routes/portfolios/test_portfolios_index.py +++ b/tests/routes/portfolios/test_portfolios_index.py @@ -88,4 +88,4 @@ def test_portfolio_reports_with_mock_portfolio(client, user_session): ) assert response.status_code == 200 assert portfolio.name in response.data.decode() - assert "$237,617.00 Total spend to date" in response.data.decode() + assert "$251,626.00 Total spend to date" in response.data.decode()