Skip to content

Add unit tests for data_utils.py#197

Open
nikhiltelkar2005-glitch wants to merge 1 commit into
52North:mainfrom
nikhiltelkar2005-glitch:add-data-utils-tests
Open

Add unit tests for data_utils.py#197
nikhiltelkar2005-glitch wants to merge 1 commit into
52North:mainfrom
nikhiltelkar2005-glitch:add-data-utils-tests

Conversation

@nikhiltelkar2005-glitch

Copy link
Copy Markdown

Related Issue / Discussion:

Fixes Issue #166

Changes:

  • New file: tests/test_data_utils.py — adds parametrized pytest unit tests for data_utils.py

Further Details:

Summary:

The file WeatherRoutingTool/algorithms/data_utils.py contained 5 testable units
(get_closest, distance, time_diffs, get_speed_from_arrival_time, and GridMixin)
but had zero test coverage — no test file referenced it anywhere.

This PR adds a new test file tests/test_data_utils.py with:

  • pytest.fixture definitions for reusable inputs (numpy arrays, route coordinates, datetime objects)
  • Parametrized tests for get_closest covering 5 edge cases (exact match, midpoint, beyond max, below min)
  • Parametrized tests for get_speed_from_arrival_time covering 3 cases using unittest.mock.patch to mock RouteParams.get_per_waypoint_coords

Before: No tests existed for data_utils.py.
After: 8 passing tests covering get_closest and get_speed_from_arrival_time.

Dependencies:

No new dependencies required. Tests use only existing packages:
pytest, numpy, astropy, unittest.mock (standard library).

PR Checklist:

In the context of this PR, I:

  • have filled the 52North Contributor License Agreement and am waiting for feedback
  • provide unit tests embedded in the WRT test framework (WeatherRoutingTool/tests) that allow the simple testing of the new/modified functionalities. All (previous and new) unit tests execute without new error messages.
  • ensure that the code formatter runs without errors/warnings
  • ensure that my changes follow the WRT's guidelines for contributing at the time of the contribution

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.

1 participant