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

Method test_upsert_uuid_unspecified

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

Source from the content-addressed store, hash-verified

418 )
419
420 def test_upsert_uuid_unspecified(self):
421 options = CodecOptions(uuid_representation=UuidRepresentation.UNSPECIFIED)
422 coll = self.coll.with_options(codec_options=options)
423 uuids = [Binary.from_uuid(uuid.uuid4()) for _ in range(3)]
424 result = coll.bulk_write(
425 [
426 UpdateOne({"_id": uuids[0]}, {"$set": {"a": 0}}, upsert=True),
427 ReplaceOne({"a": 1}, {"_id": uuids[1]}, upsert=True),
428 # This is just here to make the counts right in all cases.
429 ReplaceOne({"_id": uuids[2]}, {"_id": uuids[2]}, upsert=True),
430 ]
431 )
432 self.assertEqualResponse(
433 {
434 "nMatched": 0,
435 "nModified": 0,
436 "nUpserted": 3,
437 "nInserted": 0,
438 "nRemoved": 0,
439 "upserted": [
440 {"index": 0, "_id": uuids[0]},
441 {"index": 1, "_id": uuids[1]},
442 {"index": 2, "_id": uuids[2]},
443 ],
444 },
445 result.bulk_api_result,
446 )
447
448 def test_upsert_uuid_standard_subdocuments(self):
449 options = CodecOptions(uuid_representation=UuidRepresentation.STANDARD)

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected