Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

257 replace mocks #291

Merged
merged 11 commits into from
Dec 10, 2024
Merged

257 replace mocks #291

merged 11 commits into from
Dec 10, 2024

Conversation

charles-turner-1
Copy link
Collaborator

Closes #257, and makes some progress on #271.

Unfortunately I got mixed up and have removed a lot of the wrong mocks, but this PR currently replaces a lot of the (I think unnecessary) mocks in the tests/test_cli.py file, as well as replacing a lot of calls to the os module with pathlib.

Marked as draft because I still need to address the mocks in #257, but it seemed logical to bundle these all together.

@marc-white If you still remember the context of these tests, can you tell me if I'm violating any of the intentions with my changes?

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.49%. Comparing base (2f5ba48) to head (5834b88).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #291   +/-   ##
=======================================
  Coverage   98.49%   98.49%           
=======================================
  Files          11       11           
  Lines         996      998    +2     
=======================================
+ Hits          981      983    +2     
  Misses         15       15           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@charles-turner-1 charles-turner-1 marked this pull request as ready for review December 4, 2024 02:55
Comment on lines 222 to 225
assert (
"Expected iterable metadata columns: ['model', 'realm', 'frequency', 'variable']"
in str(excinfo.value.__cause__)
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is currently throwing me an error, I think the model column is missing.

Copy link
Collaborator Author

@charles-turner-1 charles-turner-1 Dec 4, 2024

Choose a reason for hiding this comment

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

Weird - passes on my machine & CI.

Can you show me the error message you're getting?

Copy link
Collaborator

Choose a reason for hiding this comment

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

From pytest --cov-report=term-missing --cov=access_nri_intake, I get:

FAILED tests/test_manager.py::test_CatalogManager_load_non_iterable - assert "Expected iterable metadata columns: ['model', 'realm', 'frequency', 'variable']" in "Cannot add entry with iterable metadata columns: ['realm', 'frequency', 'variable'] to dataframe catalog with iterable metadata columns: ['model', 'realm', 'frequency', 'variable'].  Please ensure that metadata ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@marc-white Is it still this same error that you're getting?

@charles-turner-1 charles-turner-1 marked this pull request as draft December 4, 2024 04:22
@charles-turner-1
Copy link
Collaborator Author

Extremely confused as to whats going on with test failures here - have moved back to draft

@marc-white
Copy link
Collaborator

Extremely confused as to whats going on with test failures here - have moved back to draft

Maybe you've got a mixed checkout locally with some out-of-date test data?

@marc-white
Copy link
Collaborator

The test conversions themselves look fine to me.

@charles-turner-1 charles-turner-1 marked this pull request as ready for review December 9, 2024 07:53
@marc-white
Copy link
Collaborator

I still get a test failure on a local checkout copy:

FAILED tests/test_manager.py::test_CatalogManager_load_non_iterable - assert "Expected iterable metadata columns: ['model', 'realm', 'frequency', 'variable']" in "Cannot add entry with iterable metadata columns: ['realm', 'frequency', 'variable'] to dataframe catalog with iterable metadata columns: ['model', 'realm', 'frequency', 'variable'].  Please ensure that metadata entrie...

@charles-turner-1
Copy link
Collaborator Author

Weird - all passing on my machine & CI - will double check whats up.

@charles-turner-1
Copy link
Collaborator Author

I still get a test failure on a local checkout copy:

FAILED tests/test_manager.py::test_CatalogManager_load_non_iterable - assert "Expected iterable metadata columns: ['model', 'realm', 'frequency', 'variable']" in "Cannot add entry with iterable metadata columns: ['realm', 'frequency', 'variable'] to dataframe catalog with iterable metadata columns: ['model', 'realm', 'frequency', 'variable'].  Please ensure that metadata entrie...

Okay, I'm confident I know the source of this - can you confirm the version of intake-dataframe-catalog you're using?

This test is checking for the upstream error message. On reflection, this level of coupling is stupid, so I've replaced it with a try & a warning if it fails. Let me know if that solves the issue for you.

Copy link
Collaborator

@marc-white marc-white left a comment

Choose a reason for hiding this comment

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

That latest update seemed to fix things. FYI, I'm on intake-dataframe-catalog=0.2.4.

@charles-turner-1
Copy link
Collaborator Author

Cool - I'm on 0.3 & I assume CI is too, so I guess that's the likely source of the error. Anyway, good catch.

@charles-turner-1 charles-turner-1 merged commit 44ad1bf into main Dec 10, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Replace mocks in test_CatalogManager_load_invalid_model
2 participants