Content-Length: 330519 | pFad | http://github.com/googleapis/google-cloud-python/commit/c9b9c9dc8b2a1f941187f71514f658976f64d76c

E1 Fix sorting 'delete_changes' in 'Watch._compute_snapshot'. (#8809) · googleapis/google-cloud-python@c9b9c9d · GitHub
Skip to content

Commit c9b9c9d

Browse files
liamuktseaver
authored andcommitted
Fix sorting 'delete_changes' in 'Watch._compute_snapshot'. (#8809)
1 parent ee416c9 commit c9b9c9d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

firestore/google/cloud/firestore_v1/watch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ def modify_doc(new_document, updated_tree, updated_map):
667667
key = functools.cmp_to_key(self._comparator)
668668

669669
# Deletes are sorted based on the order of the existing document.
670-
delete_changes = sorted(delete_changes, key=key)
670+
delete_changes = sorted(delete_changes)
671671
for name in delete_changes:
672672
change, updated_tree, updated_map = delete_doc(
673673
name, updated_tree, updated_map

firestore/tests/unit/v1/test_watch.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,28 @@ class DummyDoc(object):
736736
)
737737
self.assertEqual(updated_map, doc_map) # no change
738738

739+
def test__compute_snapshot_deletes_w_real_comparator(self):
740+
from google.cloud.firestore_v1.watch import WatchDocTree
741+
742+
doc_tree = WatchDocTree()
743+
744+
class DummyDoc(object):
745+
update_time = mock.sentinel
746+
747+
deleted_doc_1 = DummyDoc()
748+
deleted_doc_2 = DummyDoc()
749+
doc_tree = doc_tree.insert(deleted_doc_1, None)
750+
doc_tree = doc_tree.insert(deleted_doc_2, None)
751+
doc_map = {"/deleted_1": deleted_doc_1, "/deleted_2": deleted_doc_2}
752+
delete_changes = ["/deleted_1", "/deleted_2"]
753+
add_changes = []
754+
update_changes = []
755+
inst = self._makeOne(comparator=object())
756+
updated_tree, updated_map, applied_changes = inst._compute_snapshot(
757+
doc_tree, doc_map, delete_changes, add_changes, update_changes
758+
)
759+
self.assertEqual(updated_map, {})
760+
739761
def test__reset_docs(self):
740762
from google.cloud.firestore_v1.watch import ChangeType
741763

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/google-cloud-python/commit/c9b9c9dc8b2a1f941187f71514f658976f64d76c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy