# Path: tests/unit/iam_auth_tests.py
# MOCK_API_KEY = 'CqbrIYzdO3btWV-5t4teJLY_etfT_dkccq-vO-5vCXSo'


import mock
import unittest
from cloudant.database import CouchDatabase
from cloudant.replicator import Replicator
from tests.unit.iam_auth_tests import MOCK_API_KEY
        self.assertTrue(kwargs['throw_on_exists'])

    def test_using_iam_auth_source_and_target(self):
        m_iam_auth_client = self.setUpClientMocks(iam_api_key=MOCK_API_KEY)

        m_replicator = mock.MagicMock()
        m_iam_auth_client.__getitem__.return_value = m_replicator

        # create source/target databases
        src = CouchDatabase(m_iam_auth_client, self.source_db)
        tgt = CouchDatabase(m_iam_auth_client, self.target_db)

        # trigger replication
        rep = Replicator(m_iam_auth_client)
        rep.create_replication(
            src, tgt, repl_id=self.repl_id, user_ctx=self.user_ctx)

        kcall = m_replicator.create_document.call_args_list
        self.assertEqual(len(kcall), 1)
        args, kwargs = kcall[0]
        self.assertEqual(len(args), 1)

        expected_doc = {
            '_id': self.repl_id,
            'user_ctx': self.user_ctx,
            'source': {
                'auth': {'iam': {'api_key': MOCK_API_KEY}},
                'url': '/'.join((self.server_url, self.source_db))
            },
            'target': {

# Path: tests/unit/iam_auth_tests.py
# MOCK_API_KEY = 'CqbrIYzdO3btWV-5t4teJLY_etfT_dkccq-vO-5vCXSo'


# Path: tests/unit/replicator_mock_tests.py
import mock
import unittest
from cloudant.database import CouchDatabase
from cloudant.replicator import Replicator
from tests.unit.iam_auth_tests import MOCK_API_KEY

        self.assertTrue(kwargs['throw_on_exists'])

    def test_using_iam_auth_source_and_target(self):
        m_iam_auth_client = self.setUpClientMocks(iam_api_key=MOCK_API_KEY)

        m_replicator = mock.MagicMock()
        m_iam_auth_client.__getitem__.return_value = m_replicator

        # create source/target databases
        src = CouchDatabase(m_iam_auth_client, self.source_db)
        tgt = CouchDatabase(m_iam_auth_client, self.target_db)

        # trigger replication
        rep = Replicator(m_iam_auth_client)
        rep.create_replication(
            src, tgt, repl_id=self.repl_id, user_ctx=self.user_ctx)

        kcall = m_replicator.create_document.call_args_list
        self.assertEqual(len(kcall), 1)
        args, kwargs = kcall[0]
        self.assertEqual(len(args), 1)

        expected_doc = {
            '_id': self.repl_id,
            'user_ctx': self.user_ctx,
            'source': {
                'auth': {'iam': {'api_key': MOCK_API_KEY}},
                'url': '/'.join((self.server_url, self.source_db))
            },
            'target': {

                'auth': {'iam': {'api_key': MOCK_API_KEY}},