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