-
Notifications
You must be signed in to change notification settings - Fork 1
Bugfix/ogc 3388 non partly reserved slots #22
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8541f0f
Fixes reserved_slots_by_reservation dropping the slot on non-partly a…
Tschuppi81 42f40fc
Adds test
Tschuppi81 7f79f45
Update history
Tschuppi81 acc493b
Simplify things with a dedicated source_id for ReservedSlot
Tschuppi81 a838bfc
source_id shall not be nullable
Tschuppi81 313f247
Integrate pr comments
Tschuppi81 586b0b0
Fix linter
Tschuppi81 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -691,6 +691,77 @@ def test_remove_reservation_does_not_affect_sibling_reservations( | |
| assert remaining_count == slots_a_count | ||
|
|
||
|
|
||
| def test_remove_reservation_on_non_partly_allocation_removes_slot( | ||
| scheduler: Scheduler, | ||
| ) -> None: | ||
| """On a non-partly allocation the reserved slot spans the whole | ||
| allocation, even if the reservation was made for a narrower (but | ||
| contained) range. Matching slots by time range would then drop the slot, | ||
| leaving an orphaned ReservedSlot behind that keeps showing up on the | ||
| calendar after the reservation was removed (OGC-3388).""" | ||
| dates = (datetime(2014, 3, 7, 8, 0), datetime(2014, 3, 7, 18, 0)) | ||
| scheduler.allocate(dates, partly_available=False) | ||
|
|
||
| # a contained sub-range is accepted on a whole-only allocation, but the | ||
| # slot still covers the entire allocation | ||
| sub = (datetime(2014, 3, 7, 9, 0), datetime(2014, 3, 7, 17, 0)) | ||
| token = scheduler.reserve('user@example.org', sub) | ||
| scheduler.commit() | ||
| scheduler.approve_reservations(token) | ||
| scheduler.commit() | ||
|
|
||
| reservation = scheduler.reservations_by_token(token).one() | ||
| assert reservation.start is not None | ||
| assert reservation.end is not None | ||
| slot = scheduler.reserved_slots_by_reservation(token).one() | ||
| # the slot is wider than the reservation range | ||
| assert slot.start < reservation.start or slot.end > reservation.end | ||
|
|
||
| # the slot must still be attributed to this reservation ... | ||
| assert scheduler.reserved_slots_by_reservation( | ||
| token, reservation.id | ||
| ).count() == 1 | ||
|
|
||
| # ... and removing the reservation must not leave an orphaned slot | ||
| scheduler.remove_reservation(token, reservation.id) | ||
| scheduler.commit() | ||
| assert scheduler.reserved_slots_by_type(token, 'reservation').count() == 0 | ||
|
|
||
|
|
||
| def test_reserved_slots_store_source_id(scheduler: Scheduler) -> None: | ||
| """Every reserved slot records the id of its owning reservation/blocker | ||
| (source_id), so it can be attributed to its exact object directly.""" | ||
| dates = (datetime(2014, 3, 7, 8, 0), datetime(2014, 3, 7, 18, 0)) | ||
| scheduler.allocate(dates, partly_available=True) | ||
|
|
||
| token = scheduler.reserve( | ||
| 'user@example.org', | ||
| (datetime(2014, 3, 7, 8, 0), datetime(2014, 3, 7, 10, 0)) | ||
| ) | ||
| scheduler.commit() | ||
| scheduler.approve_reservations(token) | ||
| scheduler.commit() | ||
|
|
||
| reservation = scheduler.reservations_by_token(token).one() | ||
| slots = scheduler.reserved_slots_by_reservation(token).all() | ||
| assert slots | ||
| for slot in slots: | ||
| assert slot.source_type == 'reservation' | ||
| assert slot.source_id == reservation.id | ||
|
|
||
| blocker = scheduler.add_blocker( | ||
| (datetime(2014, 3, 7, 10, 0), datetime(2014, 3, 7, 12, 0)) | ||
| )[0] | ||
| assert blocker.id is not None | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| scheduler.commit() | ||
|
|
||
| blocker_slots = scheduler.reserved_slots_by_blocker(blocker.token).all() | ||
| assert blocker_slots | ||
| for slot in blocker_slots: | ||
| assert slot.source_type == 'blocker' | ||
| assert slot.source_id == blocker.id | ||
|
|
||
|
|
||
| def test_remove_blocker_does_not_affect_sibling_blockers( | ||
| scheduler: Scheduler, | ||
| ) -> None: | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.