(self)
| 133 | self.assertEqual(wc, db.write_concern) |
| 134 | |
| 135 | async def test_mongo_client(self): |
| 136 | pair = await async_client_context.pair |
| 137 | m = await self.async_rs_or_single_client(w=0) |
| 138 | coll = m.pymongo_test.write_concern_test |
| 139 | await coll.drop() |
| 140 | doc = {"_id": ObjectId()} |
| 141 | await coll.insert_one(doc) |
| 142 | self.assertTrue(await coll.insert_one(doc)) |
| 143 | coll = coll.with_options(write_concern=WriteConcern(w=1)) |
| 144 | with self.assertRaises(OperationFailure): |
| 145 | await coll.insert_one(doc) |
| 146 | |
| 147 | m = await self.async_rs_or_single_client() |
| 148 | coll = m.pymongo_test.write_concern_test |
| 149 | new_coll = coll.with_options(write_concern=WriteConcern(w=0)) |
| 150 | self.assertTrue(await new_coll.insert_one(doc)) |
| 151 | with self.assertRaises(OperationFailure): |
| 152 | await coll.insert_one(doc) |
| 153 | |
| 154 | m = await self.async_rs_or_single_client( |
| 155 | f"mongodb://{pair}/", replicaSet=async_client_context.replica_set_name |
| 156 | ) |
| 157 | |
| 158 | coll = m.pymongo_test.write_concern_test |
| 159 | with self.assertRaises(OperationFailure): |
| 160 | await coll.insert_one(doc) |
| 161 | m = await self.async_rs_or_single_client( |
| 162 | f"mongodb://{pair}/?w=0", replicaSet=async_client_context.replica_set_name |
| 163 | ) |
| 164 | |
| 165 | coll = m.pymongo_test.write_concern_test |
| 166 | await coll.insert_one(doc) |
| 167 | |
| 168 | # Equality tests |
| 169 | direct = await connected(await self.async_single_client(w=0)) |
| 170 | direct2 = await connected( |
| 171 | await self.async_single_client(f"mongodb://{pair}/?w=0", **self.credentials) |
| 172 | ) |
| 173 | self.assertEqual(direct, direct2) |
| 174 | self.assertFalse(direct != direct2) |
| 175 | |
| 176 | async def test_validate_boolean(self): |
| 177 | await self.db.test.update_one({}, {"$set": {"total": 1}}, upsert=True) |
nothing calls this directly
no test coverage detected