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

editoast: improve tests for projection #10137

Merged
merged 3 commits into from
Dec 23, 2024

Conversation

woshilapin
Copy link
Contributor

We're planning a rework of the projection algorithm to support a case that is not supported today: project multiple times the same track range (possibly different offset). This use case is brought to us by work schedule which might have this pattern.

In order to have a good refactoring without breaking anything, let's have even more tests.

Note

Review by commit

  1. first commit just make use of rstest cases to express tests in a more concise way
  2. second commit add more tests
  3. third commit, automate switching direction of inputs (multiply by 4 the numbers of tests)

Warning

The third commit significantly make the test code harder to read so I'd be happy to discuss it...

@woshilapin woshilapin requested a review from a team as a code owner December 19, 2024 14:01
@github-actions github-actions bot added the area:editoast Work on Editoast Service label Dec 19, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 89.09091% with 6 lines in your changes missing coverage. Please review.

Project coverage is 79.81%. Comparing base (1033678) to head (72eb803).
Report is 23 commits behind head on dev.

Files with missing lines Patch % Lines
editoast/src/core/pathfinding.rs 72.72% 6 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #10137      +/-   ##
==========================================
- Coverage   79.84%   79.81%   -0.03%     
==========================================
  Files        1054     1054              
  Lines      105571   105530      -41     
  Branches      726      726              
==========================================
- Hits        84292    84231      -61     
- Misses      21237    21257      +20     
  Partials       42       42              
Flag Coverage Δ
editoast 73.65% <89.09%> (-0.11%) ⬇️
front 89.15% <ø> (ø)
gateway 2.18% <ø> (ø)
osrdyne 3.28% <ø> (ø)
railjson_generator 87.50% <ø> (ø)
tests 87.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@hamz2a hamz2a left a comment

Choose a reason for hiding this comment

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

Thank you for the PR. I’ve left two comments.

All the existing test follow the same pattern.
Since we do have `rstest` that allows us to express them
as cases of the same test, let's use that.

In order to shorten (and, subjectively, make it more readable and
concise?), I also implemented a `FromStr` for `TrackRange`. It's a nice
helper to express all the tests more concisely.

Signed-off-by: Jean SIMARD <[email protected]>
It's easy to add tests, let's add some more for this tricky algorithm.

Signed-off-by: Jean SIMARD <[email protected]>
The idea is to tests all projection, and combine all possible directions.
So if we have a test on a projection of B (with direction `StartToStop`)
on A (with direction `StartToStop`), we can automate also all combinations
of directions for A and for B:
- when B is reversed, no change in the expected results (direction of the
  projected track range has no impact)
- when A is reversed, we need to calculate all the offset from the end
  and therefore, all intersections are inverted.

Signed-off-by: Jean SIMARD <[email protected]>
Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

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

LGTM. Much better!

@leovalais leovalais added this pull request to the merge queue Dec 23, 2024
Merged via the queue into dev with commit 3bc6d02 Dec 23, 2024
27 checks passed
@leovalais leovalais deleted the wsl/editoast/tests-for-projections branch December 23, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:editoast Work on Editoast Service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants