Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions process_report/tests/unit/invoices/test_moca_prepaid_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from unittest import TestCase, mock
import pandas

from process_report.tests import util as test_utils


class TestMocaPrepaidInvoice(TestCase):
def _get_test_data(self, group_managed):
return pandas.DataFrame({"MGHPCC Managed": group_managed})

def test_prepare_export(self):
test_data = self._get_test_data(group_managed=[True, False, True])
inv = test_utils.new_moca_prepaid_invoice(data=test_data)
inv._prepare_export()
assert len(inv.export_data) == 1
assert not inv.export_data.iloc[0]["MGHPCC Managed"]

def test_output_path(self):
inv = test_utils.new_moca_prepaid_invoice(invoice_month="2025-01")
assert inv.output_path == "MOCA-A_Prepaid_Groups-2025-01-Invoice.csv"

def test_output_s3_key(self):
inv = test_utils.new_moca_prepaid_invoice(invoice_month="2025-01")
assert (
inv.output_s3_key
== "Invoices/2025-01/MOCA-A_Prepaid_Groups-2025-01-Invoice.csv"
)

@mock.patch("process_report.util.get_iso8601_time")
def test_output_s3_archive_key(self, mock_get_time):
mock_get_time.return_value = "2025-01-01T00:00:00"
inv = test_utils.new_moca_prepaid_invoice(invoice_month="2025-01")
assert (
inv.output_s3_archive_key
== "Invoices/2025-01/Archive/MOCA-A_Prepaid_Groups-2025-01-Invoice 2025-01-01T00:00:00.csv"
)
13 changes: 13 additions & 0 deletions process_report/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
pi_specific_invoice,
prepay_credits_snapshot,
NERC_total_invoice,
MOCA_prepaid_invoice,
)

from process_report.processors import (
Expand Down Expand Up @@ -205,3 +206,15 @@ def new_validate_cluster_name_processor(
return validate_cluster_name_processor.ValidateClusterNameProcessor(
invoice_month, data, name
)


def new_moca_prepaid_invoice(
name="",
invoice_month="0000-00",

@knikolla knikolla Jun 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: This invoice month default parameter is highly unrealistic as no month 0 can exist. When implementing test data like this it is usually a good idea to stick with data that would be acceptable during normal operation.

data=None,
):
return MOCA_prepaid_invoice.MOCAPrepaidInvoice(
invoice_month,
data,
name,
)
Loading