Exemplo n.º 1
0
    def setup_mocked_s3_storage(self,
                                executor=TransactionExecutor,
                                executor_for_gets=TransactionExecutor,
                                storage_class='BotoS3CrashStorage',
                                host='',
                                port=0):

        config = DotDict({
            'source': {
                'dump_field': 'dump'
            },
            'transaction_executor_class':
            executor,
            'transaction_executor_class_for_get':
            executor_for_gets,
            'resource_class':
            S3ConnectionContext,
            'backoff_delays': [0, 0, 0],
            'redactor_class':
            Redactor,
            'forbidden_keys':
            Redactor.required_config.forbidden_keys.default,
            'logger':
            mock.Mock(),
            'host':
            host,
            'port':
            port,
            'access_key':
            'this is the access key',
            'secret_access_key':
            'secrets',
            'temporary_file_system_storage_path':
            self.TEMPDIR,
            'dump_file_suffix':
            '.dump',
            'bucket_name':
            'mozilla-support-reason',
            'prefix':
            'dev',
            'calling_format':
            mock.Mock()
        })
        if storage_class == 'BotoS3CrashStorage':
            config.bucket_name = 'crash_storage'
            s3 = BotoS3CrashStorage(config)
        elif storage_class == 'SupportReasonAPIStorage':
            s3 = SupportReasonAPIStorage(config)
        s3_conn = s3.connection_source
        s3_conn._connect_to_endpoint = mock.Mock()
        s3_conn._mocked_connection = s3_conn._connect_to_endpoint.return_value
        s3_conn._calling_format.return_value = mock.Mock()
        s3_conn._CreateError = mock.Mock()
        ##        s3_conn.ResponseError = mock.Mock()
        s3_conn._open = mock.MagicMock()

        return s3
Exemplo n.º 2
0
 def get_s3_store(self, tmpdir=None):
     values_source = {}
     if tmpdir is not None:
         values_source["temporary_file_system_storage_path"] = tmpdir
     return BotoS3CrashStorage(
         config=get_config(BotoS3CrashStorage, values_source))