Skip to content

Commit

Permalink
add year in reports on activities, on costs and on exceptions - #131
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard357 committed May 17, 2024
1 parent 6e40f10 commit e33da7a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions lambdas/on_activity_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,5 @@ def get_report_path(label, day=None):
day = day or date.today()
return '/'.join([os.environ["REPORTING_ACTIVITIES_PREFIX"],
label,
f"{day.year:04d}",
f"{day.year:04d}-{day.month:02d}-{label}-activities.csv"])
1 change: 1 addition & 0 deletions lambdas/on_cost_computation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def get_report_path(cost_center, label, day=None, suffix='csv'):
day = day or date.today()
return '/'.join([os.environ["REPORTING_COSTS_PREFIX"],
cost_center,
f"{day.year:04d}",
f"{day.year:04d}-{day.month:02d}-{cost_center}-{label}.{suffix}"])


Expand Down
1 change: 1 addition & 0 deletions lambdas/on_exception_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def get_report_path(label, day=None):
day = day or date.today()
return '/'.join([os.environ["REPORTING_EXCEPTIONS_PREFIX"],
label,
f"{day.year:04d}",
f"{day.year:04d}-{day.month:02d}-{label}-cost-and-usage.xlsx"])


Expand Down
4 changes: 2 additions & 2 deletions tests/test_lambda_on_activity_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,6 @@ def test_get_hashes():
@patch.dict(os.environ, dict(REPORTING_ACTIVITIES_PREFIX="all/the/activities"))
def test_get_report_path():
key = get_report_path("CostCenterOne", date(2022, 12, 25))
assert key == "all/the/activities/CostCenterOne/2022-12-CostCenterOne-activities.csv"
assert key == "all/the/activities/CostCenterOne/2022/2022-12-CostCenterOne-activities.csv"
key = get_report_path("CostCenterTwo", date(2023, 1, 2))
assert key == "all/the/activities/CostCenterTwo/2023-01-CostCenterTwo-activities.csv"
assert key == "all/the/activities/CostCenterTwo/2023/2023-01-CostCenterTwo-activities.csv"
2 changes: 1 addition & 1 deletion tests/test_lambda_on_cost_computation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_get_json_from_url():
@patch.dict(os.environ, dict(REPORTING_COSTS_PREFIX="costs"))
def test_get_report_path():
result = get_report_path(cost_center='product-a', label='charges', day=date(2023, 3, 25), suffix='xyz')
assert result == 'costs/product-a/2023-03-product-a-charges.xyz'
assert result == 'costs/product-a/2023/2023-03-product-a-charges.xyz'


@pytest.mark.unit_tests
Expand Down

0 comments on commit e33da7a

Please sign in to comment.