示例#1
0
 def add_mock_s3_data(self, bucket, path, contents, time_modified=None):
     """Update self.mock_s3_fs with a map from bucket name
     to key name to data."""
     add_mock_s3_data(self.mock_s3_fs,
                      {bucket: {path: contents}},
                      time_modified)
     return 's3://%s/%s' % (bucket, path)
示例#2
0
 def add_mock_s3_data(self, bucket, path, contents, time_modified=None):
     """Update self.mock_s3_fs with a map from bucket name
     to key name to data."""
     add_mock_s3_data(self.mock_s3_fs, {bucket: {
         path: contents
     }}, time_modified)
     return 's3://%s/%s' % (bucket, path)
示例#3
0
    def sandbox_s3(self):
        """Mock out the S3 filesystem. self.mock_s3_fs will be a map
        from bucket name to key name to contents.

        Also, add a single bucket named 'walrus'
        """
        self.mock_s3_fs = {}
        self.aws_access_key_id = None
        self.aws_secret_access_key = None

        def mock_boto_connect_s3(*args, **kwargs):
            kwargs['mock_s3_fs'] = self.mock_s3_fs

            # keep track of credentials passed explicitly to connect_s3()
            if 'aws_access_key_id' in kwargs:
                self.aws_access_key_id = kwargs['aws_access_key_id']
            if 'aws_secret_access_key' in kwargs:
                self.aws_secret_access_key = kwargs['aws_secret_access_key']

            return MockS3Connection(*args, **kwargs)

        self.monkey_patch(boto, 'connect_s3', mock_boto_connect_s3)

        add_mock_s3_data(self.mock_s3_fs, {'walrus': {}})
示例#4
0
    def sandbox_s3(self):
        """Mock out the S3 filesystem. self.mock_s3_fs will be a map
        from bucket name to key name to contents.

        Also, add a single bucket named 'walrus'
        """
        self.mock_s3_fs = {}
        self.aws_access_key_id = None
        self.aws_secret_access_key = None

        def mock_boto_connect_s3(*args, **kwargs):
            kwargs['mock_s3_fs'] = self.mock_s3_fs

            # keep track of credentials passed explicitly to connect_s3()
            if 'aws_access_key_id' in kwargs:
                self.aws_access_key_id = kwargs['aws_access_key_id']
            if 'aws_secret_access_key' in kwargs:
                self.aws_secret_access_key = kwargs['aws_secret_access_key']

            return MockS3Connection(*args, **kwargs)

        self.monkey_patch(boto, 'connect_s3', mock_boto_connect_s3)

        add_mock_s3_data(self.mock_s3_fs, {'walrus': {}})
示例#5
0
 def add_mock_s3_data(self, data):
     """Update self.mock_s3_fs with a map from bucket name
     to key name to data."""
     add_mock_s3_data(self.mock_s3_fs, data)
示例#6
0
 def add_mock_s3_data(self, data):
     """Update self.mock_s3_fs with a map from bucket name
     to key name to data."""
     add_mock_s3_data(self.mock_s3_fs, data)