-
Type: Improvement
-
Resolution: Done
-
Priority: Trivial - P5
-
Affects Version/s: None
-
Component/s: None
-
None
I'd like to mock the driver in unit tests and assert that e.g. the bulk_write method was called with some object instances, as in:
@patch('pymongo.MongoClient') def test_update(self, mock_mongo): test_items = pd.DataFrame({'id_field': [1, 2], 'foo': [42, 23]}) save_items(mock_mongo, test_items) # method under test mock_mongo.db.items.bulk_write.assert_called_with([ UpdateOne({'id_field': 1}, {'$set': {'foo': 42}}), UpdateOne({'id_field': 2}, {'$set': {'foo': 23}}) ])
However, this assertion fails because the UpdateOne class (or its superclass) doesn't have a rich comparison method such as __eq__.
Was there a specific reason for not implementing this? If not, is it ok if I implement it in e.g. the _WriteOp class and create a pull request?