MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_bulk_write

Method test_bulk_write

test/test_typing.py:171–183  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

169
170 @only_type_check
171 def test_bulk_write(self) -> None:
172 self.coll.insert_one({})
173 coll: Collection[Movie] = self.coll
174 requests: List[InsertOne[Movie]] = [InsertOne(Movie(name="American Graffiti", year=1973))]
175 self.assertTrue(coll.bulk_write(requests).acknowledged)
176 new_requests: List[Union[InsertOne[Movie], ReplaceOne[Movie]]] = []
177 input_list: List[Union[InsertOne[Movie], ReplaceOne[Movie]]] = [
178 InsertOne(Movie(name="American Graffiti", year=1973)),
179 ReplaceOne({}, Movie(name="American Graffiti", year=1973)),
180 ]
181 for i in input_list:
182 new_requests.append(i)
183 self.assertTrue(coll.bulk_write(new_requests).acknowledged)
184
185 # Because ReplaceOne is not generic, type checking is not enforced for ReplaceOne in the first example.
186 @only_type_check

Callers

nothing calls this directly

Calls 5

InsertOneClass · 0.90
ReplaceOneClass · 0.90
MovieClass · 0.70
insert_oneMethod · 0.45
bulk_writeMethod · 0.45

Tested by

no test coverage detected