Skip to content

Commit

Permalink
implement prefix for the in-memory double
Browse files Browse the repository at this point in the history
  • Loading branch information
exarkun committed Aug 24, 2017
1 parent de4d485 commit 2b6821f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions txaws/testing/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class S3ClientState(object):
``S3ClientState`` instances hold the ``_MemoryS3Client`` instance
state that is specific to testing and does not exist on
``txaws.s3.S3Client`` instances.
@ivar buckets: A ``dict`` mapping bucket identifiers to ``dict`` of
``Bucket`` and ``BucketListing`` details.
"""
from time import time

Expand Down Expand Up @@ -91,12 +94,24 @@ def delete_bucket(self, bucket):
return succeed(None)

@_rate_limited
def get_bucket(self, bucket):
def get_bucket(self, bucket, prefix=None):
try:
pieces = self._state.buckets[bucket]
except KeyError:
return fail(S3Error("<nosuchbucket/>", 400))
return succeed(pieces["listing"])
listing = pieces["listing"]
if prefix is not None:
listing = attr.assoc(
listing,
contents=list(
content
for content
in listing.contents
if content.key.startswith(prefix)
),
prefix=prefix,
)
return succeed(listing)

@_rate_limited
def get_bucket_location(self, bucket):
Expand Down

0 comments on commit 2b6821f

Please sign in to comment.