-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix diff not starting from last viewed snapshot (#2744) #2856
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
dgtlmoon
merged 2 commits into
dgtlmoon:master
from
MoshiMoshi0:2744-wrong-from-version
Dec 27, 2024
Merged
Changes from 1 commit
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ def test_watch_get_suggested_from_diff_timestamp(self): | |
watch = Watch.model(datastore_path='/tmp', default={}) | ||
watch.ensure_data_dir_exists() | ||
|
||
watch['last_viewed'] = 110 | ||
|
||
# Contents from the browser are always returned from the browser/requests/etc as str, str is basically UTF-16 in python | ||
watch.save_history_text(contents="hello world", timestamp=100, snapshot_id=str(uuid_builder.uuid4())) | ||
|
@@ -25,31 +24,38 @@ def test_watch_get_suggested_from_diff_timestamp(self): | |
watch.save_history_text(contents="hello world", timestamp=112, snapshot_id=str(uuid_builder.uuid4())) | ||
watch.save_history_text(contents="hello world", timestamp=115, snapshot_id=str(uuid_builder.uuid4())) | ||
watch.save_history_text(contents="hello world", timestamp=117, snapshot_id=str(uuid_builder.uuid4())) | ||
|
||
p = watch.get_from_version_based_on_last_viewed | ||
assert p == "100", "Correct 'last viewed' timestamp was detected" | ||
|
||
p = watch.get_next_snapshot_key_to_last_viewed | ||
assert p == "112", "Correct last-viewed timestamp was detected" | ||
watch['last_viewed'] = 110 | ||
p = watch.get_from_version_based_on_last_viewed | ||
assert p == "109", "Correct 'last viewed' timestamp was detected" | ||
|
||
# When there is only one step of difference from the end of the list, it should return second-last change | ||
watch['last_viewed'] = 116 | ||
p = watch.get_next_snapshot_key_to_last_viewed | ||
assert p == "115", "Correct 'second last' last-viewed timestamp was detected when using the last timestamp" | ||
p = watch.get_from_version_based_on_last_viewed | ||
assert p == "115", "Correct 'last viewed' timestamp was detected" | ||
|
||
watch['last_viewed'] = 99 | ||
p = watch.get_next_snapshot_key_to_last_viewed | ||
assert p == "100" | ||
p = watch.get_from_version_based_on_last_viewed | ||
assert p == "100", "When the 'last viewed' timestamp is less than the oldest snapshot, return oldest" | ||
|
||
watch['last_viewed'] = 200 | ||
p = watch.get_next_snapshot_key_to_last_viewed | ||
assert p == "115", "When the 'last viewed' timestamp is greater than the newest snapshot, return second last " | ||
p = watch.get_from_version_based_on_last_viewed | ||
assert p == "115", "When the 'last viewed' timestamp is greater than the newest snapshot, return second newest" | ||
|
||
watch['last_viewed'] = 109 | ||
p = watch.get_next_snapshot_key_to_last_viewed | ||
p = watch.get_from_version_based_on_last_viewed | ||
assert p == "109", "Correct when its the same time" | ||
|
||
# new empty one | ||
watch = Watch.model(datastore_path='/tmp', default={}) | ||
p = watch.get_next_snapshot_key_to_last_viewed | ||
p = watch.get_from_version_based_on_last_viewed | ||
assert p == None, "None when no history available" | ||
|
||
watch.save_history_text(contents="hello world", timestamp=100, snapshot_id=str(uuid_builder.uuid4())) | ||
p = watch.get_from_version_based_on_last_viewed | ||
assert p == "100", "Correct with only one history snapshot" | ||
|
||
Comment on lines
+56
to
+59
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. This could also return |
||
if __name__ == '__main__': | ||
unittest.main() |
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.