Skip to content

Add unit tests for AddInstitutionProcessor to prepare invoicing for complete automation#295

Open
marcoagonzales007 wants to merge 3 commits into
CCI-MOC:mainfrom
marcoagonzales007:add-institution-processor-tests
Open

Add unit tests for AddInstitutionProcessor to prepare invoicing for complete automation#295
marcoagonzales007 wants to merge 3 commits into
CCI-MOC:mainfrom
marcoagonzales007:add-institution-processor-tests

Conversation

@marcoagonzales007

Copy link
Copy Markdown
Contributor

part of #185

Adds unit tests for AddInstitutionProcessor, bringing coverage from 60% to 100%.

Tests added:

test_add_institution — verifies that the Institution column is correctly populated based on each PI's email domain
test_add_institution_missing_pi — verifies that rows where Manager (PI) is missing are skipped without raising an error

Also adds new_add_institution_processor() to util.py to follow the existing pattern used by all other processors.

@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

Comment thread process_report/tests/unit/processors/test_add_institution_processor.py Outdated

@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.

Two comments, and can you squash the commits of the PR afterwards?



class TestAddInstitutionProcessor(TestCase):
def _get_test_data(self, pi_names, projects=None, institutions=None):

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.

Since you're always passing in projects, you might as well remove the default option from this function. Adding the default None here suggests the projects parameter was optionally in some of your tests, which is not the case

Comment on lines +63 to +64
assert pandas.isna(output.loc[0, "Manager (PI)"])
assert output.loc[1, "Institution"] == "Boston University"

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.

Why not do assert equal on the whole dataframe, like you did in the first test?

@marcoagonzales007 marcoagonzales007 force-pushed the add-institution-processor-tests branch from 4eefaa8 to 47faa22 Compare June 9, 2026 15:46
part of CCI-MOC#185

Adds unit tests for AddInstitutionProcessor, bringing coverage from 60% to 100%.

Tests added:

test_add_institution — verifies that the Institution column is correctly populated based on each PI's email domain
test_add_institution_missing_pi — verifies that rows where Manager (PI) is missing are skipped without raising an error

Also adds new_add_institution_processor() to util.py to follow the existing pattern used by all other processors.
@marcoagonzales007 marcoagonzales007 force-pushed the add-institution-processor-tests branch from 47faa22 to 6f45e9d Compare June 9, 2026 15:48
projects=["ProjectA", "ProjectB"],
institutions=["Boston University", "MIT"],
)
answer_data = answer_data.astype(output.dtypes)

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.

Interesting. We usually don't need to cast the type of the dataframe to pass the equals() assertion. Especially with just plain str dtypes. Did you encountered an error without the casting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added it because I wasn't sure if the types would match during the comparison. I'll remove it and verify that the tests still pass without it.

@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.

Looks good!

@QuanMPhm QuanMPhm requested review from knikolla, larsks and naved001 June 29, 2026 15:07
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