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

Method test_no_remove

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

Source from the content-addressed store, hash-verified

905 coll.bulk_write([InsertOne({"x": 1})])
906
907 def test_no_remove(self):
908 # We test that an authorization failure aborts the batch and is raised
909 # as OperationFailure.
910 cli = self.rs_or_single_client_noauth(
911 username="noremove", password="pw", authSource="pymongo_test"
912 )
913 coll = cli.pymongo_test.test
914 coll.find_one()
915 requests = [
916 InsertOne({"x": 1}),
917 ReplaceOne({"x": 2}, {"x": 2}, upsert=True),
918 DeleteMany({}), # Prohibited.
919 InsertOne({"x": 3}), # Never attempted.
920 ]
921 with self.assertRaises(OperationFailure):
922 coll.bulk_write(requests) # type: ignore[arg-type]
923 self.assertEqual({1, 2}, set(self.coll.distinct("x")))
924
925
926class TestBulkWriteConcern(BulkTestBase):

Callers

nothing calls this directly

Calls 7

InsertOneClass · 0.85
ReplaceOneClass · 0.85
DeleteManyClass · 0.85
find_oneMethod · 0.45
bulk_writeMethod · 0.45
distinctMethod · 0.45

Tested by

no test coverage detected