コード例 #1
0
    def setUp(self):
        super(BotoElasticsearchDomainTestCaseBase, self).setUp()
        boto_elasticsearch_domain.__init__(self.opts)
        del self.opts

        # Set up MagicMock to replace the boto3 session
        # connections keep getting cached from prior tests, can't find the
        # correct context object to clear it. So randomize the cache key, to prevent any
        # cache hits
        conn_parameters['key'] = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(50))

        self.patcher = patch('boto3.session.Session')
        self.addCleanup(self.patcher.stop)
        self.addCleanup(delattr, self, 'patcher')
        mock_session = self.patcher.start()

        session_instance = mock_session.return_value
        self.conn = MagicMock()
        self.addCleanup(delattr, self, 'conn')
        session_instance.client.return_value = self.conn
コード例 #2
0
        }, 'msg')
    domain_ret = dict(DomainName='testdomain',
                      ElasticsearchClusterConfig={},
                      EBSOptions={},
                      AccessPolicies={},
                      SnapshotOptions={},
                      AdvancedOptions={})

log = logging.getLogger(__name__)

opts = salt.config.DEFAULT_MINION_OPTS
context = {}
utils = salt.loader.utils(opts, whitelist=['boto3'], context=context)

boto_elasticsearch_domain.__utils__ = utils
boto_elasticsearch_domain.__init__(opts)
boto_elasticsearch_domain.__salt__ = {}


class BotoElasticsearchDomainTestCaseBase(TestCase):
    conn = None

    # Set up MagicMock to replace the boto3 session
    def setUp(self):
        boto_elasticsearch_domain.__context__ = {}
        context.clear()
        # connections keep getting cached from prior tests, can't find the
        # correct context object to clear it. So randomize the cache key, to prevent any
        # cache hits
        conn_parameters['key'] = ''.join(
            random.choice(string.ascii_lowercase + string.digits)
コード例 #3
0
    }, 'msg')
    domain_ret = dict(DomainName='testdomain',
                      ElasticsearchClusterConfig={},
                      EBSOptions={},
                      AccessPolicies={},
                      SnapshotOptions={},
                      AdvancedOptions={})

log = logging.getLogger(__name__)

opts = salt.config.DEFAULT_MINION_OPTS
context = {}
utils = salt.loader.utils(opts, whitelist=['boto3'], context=context)

boto_elasticsearch_domain.__utils__ = utils
boto_elasticsearch_domain.__init__(opts)
boto_elasticsearch_domain.__salt__ = {}


class BotoElasticsearchDomainTestCaseBase(TestCase):
    conn = None

    # Set up MagicMock to replace the boto3 session
    def setUp(self):
        boto_elasticsearch_domain.__context__ = {}
        context.clear()
        # connections keep getting cached from prior tests, can't find the
        # correct context object to clear it. So randomize the cache key, to prevent any
        # cache hits
        conn_parameters['key'] = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(50))