Skip to content

[test] Add unit tests for RoutingProblem.get_power#179

Open
adity1raut wants to merge 1 commit into52North:mainfrom
adity1raut:tests/add-routing-problem-get-power-tests
Open

[test] Add unit tests for RoutingProblem.get_power#179
adity1raut wants to merge 1 commit into52North:mainfrom
adity1raut:tests/add-routing-problem-get-power-tests

Conversation

@adity1raut
Copy link
Copy Markdown

Related Issue / Discussion:

Relates to discussion [Improve Test Framework – GSoC 2025 Code Challenge]

Changes:

  • New tests/test_routing_problem_get_power.py
Screenshot From 2026-03-18 21-26-17

Further Details:

Summary:

Before: RoutingProblem.get_power and RoutingProblem._evaluate in
WeatherRoutingTool/algorithms/genetic/problem.py had zero test coverage.

After: 13 unit tests covering all methods of RoutingProblem grouped
into pytest classes, achieving 100% line coverage (34/34 statements).

Classes and tests added:

Class Tests
TestRoutingProblemInit boat_speed_from_arrival_time flag set correctly for fixed speed and arrival-time modes
TestGetPowerFixedSpeed return type, scalar fuel, positive fuel, shipparams returned, reproducibility, longer route consumes more fuel
TestGetPowerArrivalTime return type, positive fuel when speed is derived from arrival time
TestEvaluate out['F'] and out['G'] populated, out['F'] positive, out['G'] zero when no constraint violations

_evaluate is tested with unittest.mock.patch to isolate it from
get_constraints, which requires loaded constraint data not available
in the unit test environment.

Dependencies:

No new dependencies. unittest.mock is part of the Python standard library.

PR Checklist:

In the context of this PR, I:

Please consider that PRs which do not meet the requirements specified in the checklist will not be evaluated. Also, PRs with no activities will be closed after a reasonable amount of time.

Signed-off-by: Aditya Raut <araut7798@gmail.com>
@kdemmich kdemmich added the question Further information is requested label Mar 19, 2026
@kdemmich
Copy link
Copy Markdown
Collaborator

Hi @adity1raut, thank you for your PR. We appreciate the time and effort that was put into it. Please be aware that we require to follow 52 North's CLA guidelines for all PRs and, in particular, fill the 52°North Contributor License Agreement. As long as this has not been filled, I can not assign you to any issues or merge any PRs. Please don't hesitate to contact me in case of related questions.

@adity1raut
Copy link
Copy Markdown
Author

Hi @adity1raut, thank you for your PR. We appreciate the time and effort that was put into it. Please be aware that we require to follow 52 North's CLA guidelines for all PRs and, in particular, fill the 52°North Contributor License Agreement. As long as this has not been filled, I can not assign you to any issues or merge any PRs. Please don't hesitate to contact me in case of related questions.

Hi, thank you for the clarification. I have now completed the 52°North Contributor License Agreement. Please let me know if anything else is required from my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants