973 speed up test pin centring#1023
Conversation
Went back to previous commit to so need to to merge main
…tiple times, speeding up another test
| ): | ||
| mock_move_pin_into_view.side_effect = [ | ||
| mock_generator(0, 0), | ||
| mock_generator(0, 0), |
There was a problem hiding this comment.
Should: The return value for mock_generator gives us our tip_x and tip_y, so we should give it the same parameters as it was using before, in the sim_puts, (0,100).
| ) | ||
|
|
||
|
|
||
| def mock_generator(x, y): |
There was a problem hiding this comment.
Could: We are using this function to mock out the trigger_and_return_pin_tip, and it gives us a pin_x and pin_y value. I'd name it something like get_fake_pin_values_generator instead
| @patch("hyperion.experiment_plans.pin_tip_centring_plan.trigger_and_return_pin_tip") | ||
| def test_pin_tip_starting_near_negative_edge_doesnt_exceed_limit( | ||
| smargon: Smargon, oav: OAV, RE: RunEngine | ||
| mock_move_pin_into_view: MagicMock, smargon: Smargon, oav: OAV, RE: RunEngine |
There was a problem hiding this comment.
Should: This variable is the patched mock for trigger_and_return_pin_tip, so mock_move_pin_into_view should be called mock_trigger_and_return_pin_tip instead
| @patch("hyperion.experiment_plans.pin_tip_centring_plan.trigger_and_return_pin_tip") | ||
| def test_pin_tip_starting_near_positive_edge_doesnt_exceed_limit( | ||
| smargon: Smargon, oav: OAV, RE: RunEngine | ||
| mock_move_pin_into_view: MagicMock, smargon: Smargon, oav: OAV, RE: RunEngine |
There was a problem hiding this comment.
Same comment as above for this variable name
olliesilvester
left a comment
There was a problem hiding this comment.
Nice, these tests run more than 2x faster than on main. There's just a few very minor changes I've put in the comments
|
Looks good now, thanks. I'm stumped on why the CI is failing though, any ideas @dperl-dls ? |
|
@olliesilvester Just need to merge main if you want tests to pass, related to recent ispyb changes. I think it's fine to just merge this, CI will be fine in main |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1023 +/- ##
==========================================
- Coverage 93.68% 93.50% -0.19%
==========================================
Files 56 56
Lines 2708 2708
==========================================
- Hits 2537 2532 -5
- Misses 171 176 +5 ☔ View full report in Codecov by Sentry. |
DominicOram
left a comment
There was a problem hiding this comment.
Looks good, I'm glad our tests are faster now. Thanks @subinsaji!
Fixes #973
test_pin_tip_starting_near_negative_edge_doesnt_exceed_limitandtest_pin_tip_starting_near_positive_edge_doesnt_exceed_limitthat took the most time to runyield from trigger_and_return_pin_tip(oav.mxsc.pin_tip)in two test functions that took the most time.side_effectto mock generatorsTo test: