@@ -16,7 +16,6 @@ def test_watch_get_suggested_from_diff_timestamp(self):
16
16
watch = Watch .model (datastore_path = '/tmp' , default = {})
17
17
watch .ensure_data_dir_exists ()
18
18
19
- watch ['last_viewed' ] = 110
20
19
21
20
# Contents from the browser are always returned from the browser/requests/etc as str, str is basically UTF-16 in python
22
21
watch .save_history_text (contents = "hello world" , timestamp = 100 , snapshot_id = str (uuid_builder .uuid4 ()))
@@ -25,31 +24,42 @@ def test_watch_get_suggested_from_diff_timestamp(self):
25
24
watch .save_history_text (contents = "hello world" , timestamp = 112 , snapshot_id = str (uuid_builder .uuid4 ()))
26
25
watch .save_history_text (contents = "hello world" , timestamp = 115 , snapshot_id = str (uuid_builder .uuid4 ()))
27
26
watch .save_history_text (contents = "hello world" , timestamp = 117 , snapshot_id = str (uuid_builder .uuid4 ()))
27
+
28
+ p = watch .get_from_version_based_on_last_viewed
29
+ assert p == "100" , "Correct 'last viewed' timestamp was detected"
28
30
29
- p = watch .get_next_snapshot_key_to_last_viewed
30
- assert p == "112" , "Correct last-viewed timestamp was detected"
31
+ watch ['last_viewed' ] = 110
32
+ p = watch .get_from_version_based_on_last_viewed
33
+ assert p == "109" , "Correct 'last viewed' timestamp was detected"
31
34
32
- # When there is only one step of difference from the end of the list, it should return second-last change
33
35
watch ['last_viewed' ] = 116
34
- p = watch .get_next_snapshot_key_to_last_viewed
35
- assert p == "115" , "Correct 'second last' last- viewed timestamp was detected when using the last timestamp "
36
+ p = watch .get_from_version_based_on_last_viewed
37
+ assert p == "115" , "Correct 'last viewed' timestamp was detected"
36
38
37
39
watch ['last_viewed' ] = 99
38
- p = watch .get_next_snapshot_key_to_last_viewed
39
- assert p == "100"
40
+ p = watch .get_from_version_based_on_last_viewed
41
+ assert p == "100" , "When the 'last viewed' timestamp is less than the oldest snapshot, return oldest"
40
42
41
43
watch ['last_viewed' ] = 200
42
- p = watch .get_next_snapshot_key_to_last_viewed
43
- assert p == "115" , "When the 'last viewed' timestamp is greater than the newest snapshot, return second last "
44
+ p = watch .get_from_version_based_on_last_viewed
45
+ assert p == "115" , "When the 'last viewed' timestamp is greater than the newest snapshot, return second newest "
44
46
45
47
watch ['last_viewed' ] = 109
46
- p = watch .get_next_snapshot_key_to_last_viewed
48
+ p = watch .get_from_version_based_on_last_viewed
47
49
assert p == "109" , "Correct when its the same time"
48
50
49
51
# new empty one
50
52
watch = Watch .model (datastore_path = '/tmp' , default = {})
51
- p = watch .get_next_snapshot_key_to_last_viewed
53
+ p = watch .get_from_version_based_on_last_viewed
52
54
assert p == None , "None when no history available"
53
55
56
+ watch .save_history_text (contents = "hello world" , timestamp = 100 , snapshot_id = str (uuid_builder .uuid4 ()))
57
+ p = watch .get_from_version_based_on_last_viewed
58
+ assert p == "100" , "Correct with only one history snapshot"
59
+
60
+ watch ['last_viewed' ] = 200
61
+ p = watch .get_from_version_based_on_last_viewed
62
+ assert p == "100" , "Correct with only one history snapshot"
63
+
54
64
if __name__ == '__main__' :
55
65
unittest .main ()
0 commit comments