Skip to content

Add unit tests for PISpecificInvoice#305

Open
marcoagonzales007 wants to merge 2 commits into
CCI-MOC:mainfrom
marcoagonzales007:add-pi-specific-invoice-tests
Open

Add unit tests for PISpecificInvoice#305
marcoagonzales007 wants to merge 2 commits into
CCI-MOC:mainfrom
marcoagonzales007:add-pi-specific-invoice-tests

Conversation

@marcoagonzales007

Copy link
Copy Markdown
Contributor

Part of #185

Adds 3 new unit tests for PISpecificInvoice:

  1. test_export_missing_pi - verifies that rows with no PI are skipped during export
  2. test_export_no_chrome-verifies that a SystemExit is raised when Chrome is not installed
  3. test_export_s3 - Verifies that each invoice is uploaded to s3 twice(Normal & Archive)

Coverage for pi_specific_invoice.py goes from 86% to 100%

Comment on lines +198 to +202
test_invoice = self._get_test_invoice(
pi=[None, "PI1"],
institution=["", "BU"],
balance=[0, 100],
)

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.

Can you add a comment indicating that the test data is written such that one row has a missing PI? When I read it, it was not immediately clear what the test case was doing

Comment on lines +242 to +246
test_invoice = self._get_test_invoice(
pi=["PI1"],
institution=["BU"],
balance=[100],
)

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.

Given how PIInvoice is written, it is not necessary to create a test invoice for this test

"test_dir", invoice_month, data=test_invoice
)
pi_inv.export_s3(s3_bucket)
assert s3_bucket.upload_file.call_count == 2

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.

Could you make an assertion on the arguments that s3_bucket.upload_file() was called with? Otherwise, the mocking of process_report.util.get_iso8601_time was not necessary here.

@QuanMPhm QuanMPhm left a comment

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.

Just one comment. Otherwise looks good!


@mock.patch("process_report.invoices.invoice.Invoice._filter_columns")
@mock.patch("os.path.exists")
@mock.patch("subprocess.run")

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.

subprocess.run does not need to be mocked in this test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants