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

Method test_misc

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

Source from the content-addressed store, hash-verified

921
922 @client_context.require_replica_set
923 def test_misc(self):
924 # Marketing examples
925 client = self.client
926 self.addCleanup(client.drop_database, "test")
927 self.addCleanup(client.drop_database, "my_database")
928
929 # 2. Tunable consistency controls
930 collection = client.my_database.my_collection
931 with client.start_session() as session:
932 collection.insert_one({"_id": 1}, session=session)
933 collection.update_one({"_id": 1}, {"$set": {"a": 1}}, session=session)
934 for _doc in collection.find({}, session=session):
935 pass
936
937 # 3. Exploiting the power of arrays
938 collection = client.test.array_updates_test
939 collection.update_one({"_id": 1}, {"$set": {"a.$[i].b": 2}}, array_filters=[{"i.b": 0}])
940
941
942class TestTransactionExamples(IntegrationTest):

Callers

nothing calls this directly

Calls 5

addCleanupMethod · 0.80
start_sessionMethod · 0.45
insert_oneMethod · 0.45
update_oneMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected