python-mock-firestore
python-mock-firestore copied to clipboard
ArrayUnion should only add elements not already present
According to the documentation ArrayUnion should only add elements that aren't already present in the array. E.g. this test should succeed:
def test_document_update_transformerArrayUnionDuplicates(self):
fs = MockFirestore()
fs._data = {"foo": {"first": {"arr": [1, 3]}}}
fs.collection("foo").document("first").update(
{"arr": firestore.ArrayUnion([2, 3, 4])}
)
doc = fs.collection("foo").document("first").get().to_dict()
self.assertCountEqual(doc["arr"], [1, 2, 3, 4]) # fails: doc["arr"] = [1, 3, 2, 3, 4]