Skip to content

Latest commit

 

History

History
49 lines (38 loc) · 1.04 KB

s3.md

File metadata and controls

49 lines (38 loc) · 1.04 KB

S3

Used to start a S3 object storage dependency.

Specs

  • Name: s3
  • Dev Port: 9000
  • Username: admin123
  • Password: admin123

Configuration

N/A

Defaults Example

---
buckets:
  - name: mybucket
    objects:
      - name: foo.csv
        content-type: text/csv
        path: ./s3/foo.csv
      - name: test/bar.png
        content-type: image/png
        path: ./s3/bar.png

Usage Example

# Create a bucket
self.deps.s3.setup().create_bucket('bucket_name')

# Put an object in a bucket
self.deps.s3.setup().put_object('bucket_name', 'object_name', data)

# Verify an object exists in a bucket
result: bool = self.deps.s3.verify().object_exists('bucket_name', 'object_name')

If you are performing filesystem operations in your test code, you must join with get_base_path when referring to file paths. This returns the path to the "defaults" folder. For example:

path = os.path.join(self.deps.s3.get_base_path(), './s3/foo.csv')
with open(path, 'rb') as data:
    return bytes(data.read())