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

Refactor cube testing objects/mocking with DummyCube #113

Merged
merged 15 commits into from
Oct 2, 2024

Conversation

truth-quark
Copy link
Collaborator

This closes #69.

This PR covers multiple elements to switch tests to using DummyCube:

  • Replaces several Mock objs masquerading as cubes with DummyCube
  • Removes old setup cruft
  • Cleans some test fixtures
  • Adds coords to other test fixtures (fixtures better open for reuse)
  • Removes mock.patch("umpost.um2netcdf.fix_latlon_coords") in process() tests
  • BONUS: removes mock.patch("umpost.um2netcdf.fix_level_coord") in process() tests

Any comments welcome!

@truth-quark truth-quark self-assigned this Sep 26, 2024
@truth-quark truth-quark added enhancement New feature or request Release Required for next release labels Sep 26, 2024
test/test_um2netcdf.py Outdated Show resolved Hide resolved
Copy link

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

Looks pretty straightforward to me.

My main comment (which only just occurred to me, and clearly is an existing issue) is that a lot of the test assert statements don't have an explanatory note after them, e.g.:

assert False, "Well this will obviously fail"

It's nice to get an explanation out of pytest as to why a test failed, rather than having to dig into the test code itself to figure out what's going on. Up to you whether this is dealt with as part of this PR, or as a new issue.

@truth-quark
Copy link
Collaborator Author

truth-quark commented Sep 27, 2024

My main comment (which only just occurred to me, and clearly is an existing issue) is that a lot of the test assert statements don't have an explanatory note after them, e.g.:

assert False, "Well this will obviously fail"

It's nice to get an explanation out of pytest as to why a test failed, rather than having to dig into the test code itself to figure out what's going on. Up to you whether this is dealt with as part of this PR, or as a new issue.

Some of this is related to the process of retro-fitting testing & the way the code operates. Quite often, a function takes inputs, modifies a cube & returns None. Error messages could make it clearer if a value hasn't been set properly.

This relates to another element: being unfamiliar with why steps are done, thus not knowing what meaningful error msg to provide (or in some cases, if the code is doing the right thing).

There's also a future refactoring step where I suspect simplification could result in shrinking the code & tests. At this stage I'm mainly focusing on code coverage to assist with the rework steps.

test/test_um2netcdf.py Show resolved Hide resolved
test/test_um2netcdf.py Show resolved Hide resolved
test/test_um2netcdf.py Show resolved Hide resolved
test/test_um2netcdf.py Show resolved Hide resolved
test/test_um2netcdf.py Show resolved Hide resolved
@truth-quark truth-quark mentioned this pull request Sep 30, 2024
18 tasks
@truth-quark
Copy link
Collaborator Author

My main comment (which only just occurred to me, and clearly is an existing issue) is that a lot of the test assert statements don't have an explanatory note after them, e.g.:

assert False, "Well this will obviously fail"

It's nice to get an explanation out of pytest as to why a test failed, rather than having to dig into the test code itself to figure out what's going on. Up to you whether this is dealt with as part of this PR, or as a new issue.

I've added this to #27 for feature fixes too.

@truth-quark truth-quark mentioned this pull request Oct 2, 2024
Copy link
Collaborator

@blimlim blimlim left a comment

Choose a reason for hiding this comment

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

Nice! Looks good to me!

@truth-quark truth-quark merged commit 962fa50 into main Oct 2, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Release Required for next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor coord mocks when #63/lat long fixes is merged
3 participants