Repository navigation
grass.jupyter: add tests for utils helpers - #7486
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds unit tests for pure helper functions in grass.jupyter.utils to validate rendering size calculation and map-name extraction from display commands.
Changes:
- Introduces parametrized tests for
get_rendering_size()covering explicit dimensions, aspect-ratio-derived dimensions, and default sizing behavior. - Adds tests for
get_map_name_from_d_command()across common display modules and edge cases (missing parameter, non-string values).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
get_rendering_size and get_map_name_from_d_command in grass.jupyter.utils had no direct test coverage. Both are pure, deterministic, and free of rendering or optional mapping dependencies. Add a pytest module covering get_rendering_size across all aspect-ratio branches and get_map_name_from_d_command across its default, per-command special-case, missing, and non-string inputs.
2e9a541 to
c712d31
Compare
cwhite911
left a comment
There was a problem hiding this comment.
@Valyrian-Code this looks good. I just have a few additional edge cases you could add.
Following review: add get_map_name_from_d_command cases for map=None and for multiple maps passed to d.rgb (only the primary red map is returned), and get_rendering_size cases documenting round()'s half-to-even behavior (2.5 -> 2, 3.5 -> 4).
|
Thanks for the review @cwhite911 - added all three edge cases in b2d28fc (map=None, the d.rgb multi-map case returning only red_map, and the two round() half-to-even cases). Ready for another look. |
|
Thanks again @cwhite911, this was a really helpful review. I enjoyed working in If there are other Just point me at whatever would be most useful, and thanks for the warm welcome to the project. |
cwhite911
left a comment
There was a problem hiding this comment.
Thanks @Valyrian-Code. Looks good!
|
There was a hang in a t.list on macOS, killed after 5 minutes (expecting at most seconds), 296.33s call temporal/t.list/tests/test_t_list.py::test_t_list_csv[,]. What I find interesting is a warning related to an unclosed TextIOWriter https://github.com/OSGeo/grass/actions/runs/27020186894/job/79745720633?pr=7486#step:14:1749. I wouldn’t investigate the process still running before making sure it is not only code coverage that hasn’t still finished saving the data file. |
|
For the windows failure, it seems Cairo was changed in osgeo4w yesterday, in the following commit, and some patch mentioning the header file changed. jef-n/OSGeo4W@c3b8830 I didn’t have time to finish looking and understanding |
Looks like the cairo header was moved from I'll open a PR #7507. |
* grass.jupyter: add tests for utils helpers get_rendering_size and get_map_name_from_d_command in grass.jupyter.utils had no direct test coverage. Both are pure, deterministic, and free of rendering or optional mapping dependencies. Add a pytest module covering get_rendering_size across all aspect-ratio branches and get_map_name_from_d_command across its default, per-command special-case, missing, and non-string inputs. * grass.jupyter: add edge-case tests for utils helpers Following review: add get_map_name_from_d_command cases for map=None and for multiple maps passed to d.rgb (only the primary red map is returned), and get_rendering_size cases documenting round()'s half-to-even behavior (2.5 -> 2, 3.5 -> 4).
Description
Add unit tests for two pure helper functions in
grass.jupyter.utilsthatwere previously untested:
get_rendering_size— covers all aspect-ratio branches (both dimensionsgiven, only width, only height, taller-than-wide, wider-than-tall) plus a
custom-defaults case.
get_map_name_from_d_command— covers the defaultmapparameter, theper-command special cases (
d.his,d.legend,d.rgb,d.shade), amissing parameter, and a non-string value.
Motivation and context
grass.jupyter.utilshas several pure helpers with no direct test coverage.These two are deterministic and dependency-free (no rendering or optional
mapping libraries), so they are a good, low-risk place to start adding
coverage.
How has this been tested?
pytest python/grass/jupyter/tests/grass_jupyter_utils_test.py— 14 testspass.
ruff formatandruff checkare clean.Types of changes