def test_sigv4_only_region(tmpdir, monkeypatch): monkeypatch.setenv('AWS_REGION', 'eu-central-1') sigv4_check_apply() bucket_name = bucket_name_mangle('sigv4') creds = Credentials(os.getenv('AWS_ACCESS_KEY_ID'), os.getenv('AWS_SECRET_ACCESS_KEY')) cinfo = calling_format.from_store_name(bucket_name) conn = cinfo.connect(creds) try: conn.create_bucket(bucket_name, location='eu-central-1') except boto.exception.S3CreateError: pass source = unicode(tmpdir.join('source')) contents = 'abcdefghijklmnopqrstuvwxyz\n' * 100 with open(source, 'wb') as f: f.write(contents) data_url = 's3://{0}/data'.format(bucket_name) with open(source) as f: uri_put_file(creds, data_url, f) results = uri_get_file(creds, data_url) assert contents == results
def load_detail(self, conn): if self._details_loaded: return uri = "{scheme}://{bucket}/{path}".format( scheme=self.layout.scheme, bucket=self.layout.store_name(), path=self.layout.basebackup_sentinel(self)) data = json.loads(s3.uri_get_file(None, uri, conn=conn)) for k, v in data.items(): setattr(self, k, v) self._details_loaded = True
def upload_download(): """ Test uri_put_file and uri_get_file in eu-central-1""" source = str(tmpdir.join('source')) contents = b'abcdefghijklmnopqrstuvwxyz\n' * 100 with open(source, 'wb') as f: f.write(contents) data_url = 's3://{0}/data'.format(bucket_name) with open(source) as f: uri_put_file(creds, data_url, f) results = uri_get_file(creds, data_url) assert contents == results
def upload_download(): """ Test uri_put_file and uri_get_file in eu-central-1""" source = str(tmpdir.join("source")) contents = b"abcdefghijklmnopqrstuvwxyz\n" * 100 with open(source, "wb") as f: f.write(contents) data_url = "s3://{0}/data".format(bucket_name) with open(source) as f: uri_put_file(creds, data_url, f) results = uri_get_file(creds, data_url) assert contents == results