コード例 #1
0
ファイル: __init__.py プロジェクト: nathancahill/mimicdb
    def get_key_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)
        key = Key(bucket)
        key.key = 'upload'

        assert key.key == 'upload'
コード例 #2
0
    def get_key_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)
        key = Key(bucket)
        key.key = 'upload'

        assert key.key == 'upload'
コード例 #3
0
    def track_upload_init_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)

        key = Key(bucket, 'track')
        key.set_contents_from_string('track')

        assert 'track' in mimicdb.backend.smembers(tpl.bucket % self.name)
コード例 #4
0
    def set_key_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)
        key = Key(bucket)
        key.key = 'upload'

        assert key.size == len('upload')
        assert key.md5 == hashlib.md5('upload').hexdigest()
コード例 #5
0
ファイル: __init__.py プロジェクト: nathancahill/mimicdb
    def track_upload_init_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)

        key = Key(bucket, 'track')
        key.set_contents_from_string('track')

        assert 'track' in mimicdb.backend.smembers(tpl.bucket % self.name)
コード例 #6
0
ファイル: __init__.py プロジェクト: nathancahill/mimicdb
    def set_key_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)
        key = Key(bucket)
        key.key = 'upload'

        assert key.size == len('upload')
        assert key.md5 == hashlib.md5('upload').hexdigest()  
コード例 #7
0
    def track_upload_meta_init_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)

        key = Key(bucket, 'track')
        key.set_contents_from_string('track')

        meta = mimicdb.backend.hgetall(tpl.key % (self.name, 'track'))

        assert int(meta['size']) == len('track')
        assert meta['md5'] == hashlib.md5('track').hexdigest()
コード例 #8
0
ファイル: __init__.py プロジェクト: nathancahill/mimicdb
    def track_upload_meta_init_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)

        key = Key(bucket, 'track')
        key.set_contents_from_string('track')

        meta = mimicdb.backend.hgetall(tpl.key % (self.name, 'track'))

        assert int(meta['size']) == len('track')
        assert meta['md5'] == hashlib.md5('track').hexdigest()
コード例 #9
0
    def get_unassigned_key_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)
        key = Key(bucket)

        assert key.key == None
コード例 #10
0
ファイル: bucket.py プロジェクト: tlevine/mimicdb
    def _get_key_internal(self, *args, **kwargs):
        """
        Internal method for checking if a key exists in the bucket set. Returns
        None if not. If 'force' is in the headers, it checks S3 for the key.
        """
        if 'force' in kwargs.get('headers', args[1] if len(args) > 1 else {}) or kwargs.pop('force', None):
            return super(Bucket, self)._get_key_internal(*args, **kwargs)

        key = None

        if mimicdb.redis.sismember(self.name, args[0]):
            key = Key(self)

        return key, None
コード例 #11
0
    def track_download_meta_test(self):
        self.conn.sync()

        bucket = self.conn.get_bucket(self.name)

        key = BotoKey(self.boto_bucket)
        key.key = 'download'
        key.set_contents_from_string('download')

        key = Key(bucket)
        key.key = 'download'
        key.get_contents_as_string()

        meta = mimicdb.backend.hgetall(tpl.key % (self.name, 'download'))

        assert int(meta['size']) == len('download')
        assert meta['md5'] == hashlib.md5('download').hexdigest()
コード例 #12
0
ファイル: bucket.py プロジェクト: tlevine/mimicdb
    def list(self, *args, **kwargs):
        """
        Returns an iterable of keys in the bucket set. If 'force' is passed,
        it passes it to the internal function using the headers hack.

        """
        if kwargs.pop('force', None):
            headers = kwargs.get('headers', {})
            headers['force'] = 'True'
            kwargs['headers'] = headers

            for key in super(Bucket, self).list(*args, **kwargs):
                yield key

        else:
            prefix = kwargs.get('prefix', args[0] if args else '')

            for key in mimicdb.redis.smembers(self.name):
                if key.startswith(prefix):
                    yield Key(self, key)