-
Notifications
You must be signed in to change notification settings - Fork 0
Unify UUID, pagination and intervals #8
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
corentinmusard
merged 2 commits into
main
from
corentinmusard/tbx-2519-refactor-unify-some-protobuf-messages-eg-only-one-uuid
Jul 16, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from hypothesis.strategies import DrawFn, booleans, composite, just, one_of, uuids | ||
|
|
||
| from tilebox.datasets.query.id_interval import IDInterval, IDIntervalLike | ||
|
|
||
|
|
||
| @composite | ||
| def id_intervals(draw: DrawFn) -> IDInterval: | ||
| """A hypothesis strategy for generating random id intervals""" | ||
| start = draw(uuids(version=4)) | ||
| end = draw(uuids(version=4)) | ||
| start, end = min(start, end), max(start, end) # make sure start is before end | ||
|
|
||
| start_exclusive = draw(booleans()) | ||
| end_inclusive = draw(booleans()) | ||
|
|
||
| return IDInterval(start, end, start_exclusive, end_inclusive) | ||
|
|
||
|
|
||
| @composite | ||
| def id_intervals_like(draw: DrawFn) -> IDIntervalLike: | ||
| """A hypothesis strategy for generating random id intervals""" | ||
| interval = draw(id_intervals()) | ||
| return draw( | ||
| one_of( | ||
| just(interval), | ||
| just((str(interval.start_id), str(interval.end_id))), | ||
| just((interval.start_id, interval.end_id)), | ||
| ) | ||
| ) |
10 changes: 2 additions & 8 deletions
10
tilebox-datasets/tests/data/pagination.py → tilebox-datasets/tests/query/pagination.py
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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from hypothesis import given | ||
| from tests.query.datapoint import id_intervals, id_intervals_like | ||
|
|
||
| from tilebox.datasets.query.id_interval import IDInterval, IDIntervalLike | ||
|
|
||
|
|
||
| @given(id_intervals()) | ||
| def test_id_intervals_to_message_and_back(interval: IDInterval) -> None: | ||
| assert IDInterval.from_message(interval.to_message()) == interval | ||
|
|
||
|
|
||
| @given(id_intervals_like()) | ||
| def test_parse_id_interval_from_tuple(interval: IDIntervalLike) -> None: | ||
| parsed = IDInterval.parse(interval) | ||
|
|
||
| if isinstance(interval, IDInterval): | ||
| assert parsed == interval, f"Failed parsing interval from {interval}" | ||
| assert parsed.start_exclusive == interval.start_exclusive | ||
| assert parsed.end_inclusive == interval.end_inclusive | ||
| else: | ||
| assert not parsed.start_exclusive | ||
| assert parsed.end_inclusive |
4 changes: 2 additions & 2 deletions
4
...ox-datasets/tests/data/test_pagination.py → ...x-datasets/tests/query/test_pagination.py
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
Oops, something went wrong.
Oops, something went wrong.
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.