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

Method test_upsert_uuid_standard

test/test_bulk.py:392–418  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

390 )
391
392 def test_upsert_uuid_standard(self):
393 options = CodecOptions(uuid_representation=UuidRepresentation.STANDARD)
394 coll = self.coll.with_options(codec_options=options)
395 uuids = [uuid.uuid4() for _ in range(3)]
396 result = coll.bulk_write(
397 [
398 UpdateOne({"_id": uuids[0]}, {"$set": {"a": 0}}, upsert=True),
399 ReplaceOne({"a": 1}, {"_id": uuids[1]}, upsert=True),
400 # This is just here to make the counts right in all cases.
401 ReplaceOne({"_id": uuids[2]}, {"_id": uuids[2]}, upsert=True),
402 ]
403 )
404 self.assertEqualResponse(
405 {
406 "nMatched": 0,
407 "nModified": 0,
408 "nUpserted": 3,
409 "nInserted": 0,
410 "nRemoved": 0,
411 "upserted": [
412 {"index": 0, "_id": uuids[0]},
413 {"index": 1, "_id": uuids[1]},
414 {"index": 2, "_id": uuids[2]},
415 ],
416 },
417 result.bulk_api_result,
418 )
419
420 def test_upsert_uuid_unspecified(self):
421 options = CodecOptions(uuid_representation=UuidRepresentation.UNSPECIFIED)

Callers

nothing calls this directly

Calls 6

CodecOptionsClass · 0.90
UpdateOneClass · 0.85
ReplaceOneClass · 0.85
with_optionsMethod · 0.45
bulk_writeMethod · 0.45
assertEqualResponseMethod · 0.45

Tested by

no test coverage detected