Skip to content

Commit ff87926

Browse files
authored
Merge pull request #296 from QuanMPhm/fix/daily_quotachar
Changed quote char parsing in fetch_daily_billable_usage command
2 parents 643fa00 + a85d04d commit ff87926

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/coldfront_plugin_cloud/management/commands/fetch_daily_billable_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def load_csv(location) -> DataFrameGroupBy:
194194
location,
195195
engine="pyarrow",
196196
dtype={INVOICE_COLUMN_COST: pandas.ArrowDtype(pyarrow.decimal128(12, 2))},
197+
quotechar="|",
197198
)
198199
return df.groupby(INVOICE_COLUMN_ALLOCATION_ID)
199200

src/coldfront_plugin_cloud/tests/unit/test_fetch_daily_billable_usage.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
from django.core.management import call_command
1616

17-
17+
# Quote char `|` should be read correctly by fetch command
1818
TEST_INVOICE = """
1919
Project - Allocation ID,SU Type,Cost
20-
test-allocation-1,OpenStack CPU,100.25
21-
test-allocation-1,OpenStack V100 GPU,500.37
20+
|test-allocation-1, foo|,OpenStack CPU,100.25
21+
|test-allocation-1, foo|,OpenStack V100 GPU,500.37
2222
test-allocation-2,OpenStack CPU,0.25
2323
"""
2424

@@ -75,7 +75,9 @@ def test_read_csv_and_get_allocation_usage(self, mock_load_service_invoice):
7575
invoice = c.load_csv(test_invoice_data)
7676
mock_load_service_invoice.return_value = invoice
7777

78-
usage_info = c.get_allocation_usage("Test", "2025-01-11", "test-allocation-1")
78+
usage_info = c.get_allocation_usage(
79+
"Test", "2025-01-11", "test-allocation-1, foo"
80+
)
7981
usage_info_dict = usage_models.to_dict(usage_info)
8082

8183
self.assertEqual(usage_info_dict["OpenStack CPU"], "100.25")

0 commit comments

Comments
 (0)