class MockTestCase(unittest.TestCase): @mock.patch('pymongo.Connection') def setUp(self, pymongo_mock): self.p = Processor(connection=pymongo_mock) def test_add(self): self.p.run_process() self.p.document_collection.save.assert_called_with({ '_type': '1', '_id': 1, '_source': {'body': 'test', 'id': 1, 'dtyp': '1'}, '_index': ''})
def test_add(self): mock_connection = self.mocker.replace(pymongo.Connection) mock_connection.test_database mock_db = self.mocker.mock() self.mocker.result(mock_db) mock_db.documents.save({ '_type': '1', '_id': 1, '_source': {'body': 'test', 'id': 1, 'dtyp': '1'}, '_index': ''}) self.mocker.replay() p = Processor(connection=mock_connection) p.run_process()
def setUp(self, pymongo_mock): self.p = Processor(connection=pymongo_mock)