Skip to content

Commit 8bcfa64

Browse files
Add unit tests for PrepayCreditsSnapshot
Part of #185 Adds unit tests for PrepayCreditsSnapshot bringing the coverage from 85% to 100%. Tests added: - test_output_path: verifies the output filename is correctly formatted - test_output_s3_key: verifies the S3 path is correctly formatted - test_output_s3_archive_key: verifies the S3 archive path is correctly formatted - test_get_credit_snapshot: verifies that prepare correctly filters credits to only managed groups for the invoice month
1 parent 72b6e76 commit 8bcfa64

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

process_report/tests/unit/invoices/test_credits_snapshot.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest import TestCase
1+
from unittest import TestCase, mock
22
import pandas
33

44
from process_report.tests import util as test_utils
@@ -36,6 +36,26 @@ def test_get_credit_snapshot(self):
3636
prepay_credits=test_prepay_credits,
3737
prepay_contacts=test_prepay_contacts,
3838
)
39-
output_snapshot = new_prepayment_proc._get_prepay_credits_snapshot()
39+
new_prepayment_proc._prepare()
40+
assert answer_credits_snapshot.equals(new_prepayment_proc.export_data)
4041

41-
assert answer_credits_snapshot.equals(output_snapshot)
42+
def test_output_path(self):
43+
inv = test_utils.new_prepay_credits_snapshot(invoice_month="2025-01")
44+
45+
assert inv.output_path == "NERC_Prepaid_Group-Credits-2025-01.csv"
46+
47+
def test_output_s3_key(self):
48+
inv = test_utils.new_prepay_credits_snapshot(invoice_month="2025-01")
49+
assert (
50+
inv.output_s3_key
51+
== "Invoices/2025-01/NERC_Prepaid_Group-Credits-2025-01.csv"
52+
)
53+
54+
@mock.patch("process_report.util.get_iso8601_time")
55+
def test_output_s3_archive_key(self, mock_time):
56+
mock_time.return_value = "2025-01-01T00:00:00"
57+
inv = test_utils.new_prepay_credits_snapshot(invoice_month="2025-01")
58+
assert (
59+
inv.output_s3_archive_key
60+
== "Invoices/2025-01/Archive/NERC_Prepaid_Group-Credits-2025-01 2025-01-01T00:00:00.csv"
61+
)

0 commit comments

Comments
 (0)