Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listing of keys is inconsistent with boto's implementation #14

Closed
antimora opened this issue Apr 13, 2013 · 0 comments
Closed

listing of keys is inconsistent with boto's implementation #14

antimora opened this issue Apr 13, 2013 · 0 comments

Comments

@antimora
Copy link
Contributor

The following code demonstrates that the listing of keys is inconsistent with boto's implementation.

Here is the output:

real s3
[u'toplevel/x/key', u'toplevel/x/y/key', u'toplevel/x/y/z/key', u'toplevel/y.key1', u'toplevel/y.key2', u'toplevel/y.key3']
[u'toplevel/y.key1', u'toplevel/y.key2', u'toplevel/y.key3', u'toplevel/x/']

mocked s3
[u'toplevel/y.key1', u'toplevel/y.key2', u'toplevel/y.key3', u'toplevel/x']
[u'toplevel/y.key1', u'toplevel/y.key2', u'toplevel/y.key3', u'toplevel/x']

The test code:

import boto
from boto.s3.key import Key
from moto import mock_s3

BUCKET = 'dilshodtest1bucket'
prefix = 'toplevel/'

def main():

    conn = boto.connect_s3()
    conn.create_bucket(BUCKET)
    bucket = conn.get_bucket(BUCKET)

    def store(name):
        k = Key(bucket, prefix + name)
        k.set_contents_from_string('somedata')

    names = ['x/key', 'y.key1', 'y.key2', 'y.key3', 'x/y/key', 'x/y/z/key']

    for name in names:
        store(name)

    delimiter = None

    keys = [x.name for x in bucket.list(prefix, delimiter)]

    print keys

    delimiter = '/'
    keys = [x.name for x in bucket.list(prefix, delimiter)]

    print keys


if __name__ == '__main__':

    print 'real s3'

    main()

    print 'mocked s3'

    mock = mock_s3()
    mock.start()
    main()
    mock.stop()
@spulec spulec closed this as completed in be26daa Apr 13, 2013
spulec added a commit that referenced this issue May 7, 2013
spulec pushed a commit that referenced this issue Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant