python-mock-firestore icon indicating copy to clipboard operation
python-mock-firestore copied to clipboard

ArrayUnion should only add elements not already present

Open hellojappie opened this issue 3 years ago • 0 comments

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]

hellojappie avatar Mar 03 '22 09:03 hellojappie