Add unit tests for PISpecificInvoice#305
Open
marcoagonzales007 wants to merge 2 commits into
Open
Conversation
QuanMPhm
requested changes
Jun 12, 2026
Comment on lines
+198
to
+202
| test_invoice = self._get_test_invoice( | ||
| pi=[None, "PI1"], | ||
| institution=["", "BU"], | ||
| balance=[0, 100], | ||
| ) |
Contributor
There was a problem hiding this comment.
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], | ||
| ) |
Contributor
There was a problem hiding this comment.
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 |
Contributor
There was a problem hiding this comment.
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
requested changes
Jun 29, 2026
QuanMPhm
left a comment
Contributor
There was a problem hiding this comment.
Just one comment. Otherwise looks good!
|
|
||
| @mock.patch("process_report.invoices.invoice.Invoice._filter_columns") | ||
| @mock.patch("os.path.exists") | ||
| @mock.patch("subprocess.run") |
Contributor
There was a problem hiding this comment.
subprocess.run does not need to be mocked in this test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #185
Adds 3 new unit tests for PISpecificInvoice:
test_export_missing_pi- verifies that rows with no PI are skipped during exporttest_export_no_chrome-verifies that a SystemExit is raised when Chrome is not installedtest_export_s3- Verifies that each invoice is uploaded to s3 twice(Normal & Archive)Coverage for
pi_specific_invoice.pygoes from 86% to 100%