Skip to content

Commit

Permalink
Plopezpe/add static subscription name (#459)
Browse files Browse the repository at this point in the history
* add subscription name to reports --version-two if exist at yml

* add user key data to static file to improve coverage

* add same subs id than static file in the test

* Bump minor version number

---------

Co-authored-by: Pedro Lopez <>
Co-authored-by: Luke Couzens <lcouzens@redhat.com>
  • Loading branch information
pedrolp85 and lcouzens authored Aug 8, 2023
1 parent 7bd91d3 commit de14a69
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "4.3.2"
__version__ = "4.3.3"

VERSION = __version__.split(".")
4 changes: 3 additions & 1 deletion nise/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,15 @@ def _generate_azure_account_info(static_report_data=None):
company_name = fake.company()
company_email = company_name.replace(" ", "").replace(",", "")
email_suffix = f"@{company_email}.com"
subscription_name = f"{company_name} Azure Subscription"

billing_account_id = fake.ean(length=8)
billing_account_name = company_name
accounts = []
if static_report_data:
subscription_guid = static_report_data.get("payer")
usage_accounts = tuple(static_report_data.get("user"))
currency_code = static_report_data.get("currency_code", "USD")
subscription_name = static_report_data.get("subscription_name", f"{company_name} Azure Subscription")
for _ in usage_accounts:
account_name = fake.city()
trimmed_account_name = account_name.replace(" ", "")
Expand All @@ -379,6 +380,7 @@ def _generate_azure_account_info(static_report_data=None):
fake.ean(length=13),
)
currency_code = "USD"
subscription_name = f"{company_name} Azure Subscription"
for _ in usage_accounts:
account_name = fake.city()
trimmed_account_name = account_name.replace(" ", "")
Expand Down
8 changes: 7 additions & 1 deletion tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,12 @@ def test_azure_create_report_with_static_data(self, mock_name):
"end_date": str(now.date() + relativedelta(months=+2)),
}
},
]
],
"accounts": {
"payer": "38f1d748-3ac7-4b7f-a5ae-8b5ff16db82c",
"user": ["38f1d748-3ac7-4b7f-a5ae-8b5ff16db82c"],
"subscription_name": "static_subscription_name",
},
}
options = {
"start_date": yesterday,
Expand All @@ -1205,6 +1210,7 @@ def test_azure_create_report_with_static_data(self, mock_name):
"static_report_data": static_azure_data,
"write_monthly": True,
}

azure_create_report(options)
local_path = self.MOCK_AZURE_REPORT_FILENAME
self.assertTrue(os.path.isfile(local_path))
Expand Down

0 comments on commit de14a69

Please sign in to comment.