Skip to content

Commit

Permalink
[COST-3883] Fixing Start date for Azure/AWS (#4529)
Browse files Browse the repository at this point in the history
* Fixing Start date for Azure/AWS
  • Loading branch information
lcouzens committed Jul 2, 2023
1 parent a64b90e commit 84c0b55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
18 changes: 5 additions & 13 deletions koku/api/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,8 @@ def test_get_months_in_date_range__report_with_no_dates_year_start(self, mock_dh
"schema": "org1234567",
"provider_uuid": "f3da28f7-00c7-43ba-a1de-f0be0b9d6060",
}
_start_date_1 = self.first_of_year - datetime.timedelta(days=2)
expected_start_1 = _start_date_1.strftime("%Y-%m-%d")
_end_date_1 = _start_date_1 + relativedelta(day=31)
expected_end_1 = _end_date_1.date().strftime("%Y-%m-%d")
expected_date_2 = self.first_of_year.strftime("%Y-%m-%d")
expected_months = [(expected_start_1, expected_end_1, None), (expected_date_2, expected_date_2, None)]
expected_months = [(expected_date_2, expected_date_2, None)]

returned_months = get_months_in_date_range(test_report)

Expand All @@ -363,18 +359,14 @@ def test_get_months_in_date_range__report_with_no_dates_month_start(self, mock_d
with a report missing start, end or both dates
returns list of month tuples during first of a month
"""

mock_dh_today.return_value = self.first_of_month
end_date = self.first_of_month.replace(day=3)
mock_dh_today.return_value = end_date
test_report = {
"schema": "org1234567",
"provider_uuid": "f3da28f7-00c7-43ba-a1de-f0be0b9d6060",
}
_start_date_1 = self.first_of_month - datetime.timedelta(days=2)
expected_start_1 = _start_date_1.strftime("%Y-%m-%d")
_end_date_1 = _start_date_1 + relativedelta(day=31)
expected_end_1 = _end_date_1.date().strftime("%Y-%m-%d")
expected_date_2 = self.first_of_month.strftime("%Y-%m-%d")
expected_months = [(expected_start_1, expected_end_1, None), (expected_date_2, expected_date_2, None)]
expected_date = self.first_of_month.strftime("%Y-%m-%d")
expected_months = [(expected_date, end_date.strftime("%Y-%m-%d"), None)]

returned_months = get_months_in_date_range(test_report)

Expand Down
2 changes: 1 addition & 1 deletion koku/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def get_months_in_date_range(
)
else:
LOG.info("generating start and end dates for manifest")
dt_start = dh.today - datetime.timedelta(days=2)
dt_start = dh.today - datetime.timedelta(days=2) if dh.today.date().day > 2 else dh.today.replace(day=1)
dt_end = dh.today

elif dt_invoice_month:
Expand Down
2 changes: 1 addition & 1 deletion koku/masu/test/processor/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def test_summarize_reports_processing_list_with_none(self, mock_update_summary):

summarize_reports(reports_to_summarize)

mock_update_summary.s.assert_called_once()
mock_update_summary.s.assert_called()

@patch("masu.processor.tasks.update_summary_tables")
def test_summarize_reports_processing_list_only_none(self, mock_update_summary):
Expand Down

0 comments on commit 84c0b55

Please sign in to comment.