def tearDown(self): with cloudant(self.user, self.passwd) as c: replicator_db = ReplicatorDatabase(c) while self.replication_ids: replicator_db.stop_replication(self.replication_ids.pop()) while self.dbs: c.delete_database(self.dbs.pop())
def test_stop_replication(self): """test stop_replication call""" mock_account = mock.Mock() repl = ReplicatorDatabase(mock_account) mock_doc = mock.Mock() mock_doc.fetch = mock.Mock() mock_doc.delete = mock.Mock() repl['replication_1'] = mock_doc repl.stop_replication('replication_1') self.assertTrue(mock_doc.fetch.called) self.assertTrue(mock_doc.delete.called) with mock.patch('cloudant.replicator.ReplicatorDatabase.__getitem__') as mock_gi: mock_gi.side_effect = KeyError("womp") self.assertRaises( CloudantException, repl.stop_replication, 'replication_2' )