Example #1
0
    def test_storage(self):

        store = dict()
        a = Attributes(store=store, key='attrs')
        assert 'foo' not in a
        assert 'bar' not in a
        assert dict() == a.asdict()

        a['foo'] = 'bar'
        a['baz'] = 42
        assert 'attrs' in store
        assert isinstance(store['attrs'], bytes)
        d = json.loads(str(store['attrs'], 'ascii'))
        assert dict(foo='bar', baz=42) == d
Example #2
0
    def test_storage(self):

        store = dict()
        a = Attributes(store=store, key='attrs')
        assert 'foo' not in a
        assert 'bar' not in a
        eq(dict(), a.asdict())

        a['foo'] = 'bar'
        a['baz'] = 42
        assert 'attrs' in store
        assert isinstance(store['attrs'], binary_type)
        d = json.loads(text_type(store['attrs'], 'ascii'))
        eq(dict(foo='bar', baz=42), d)
Example #3
0
    def test_storage(self):

        store = dict()
        a = Attributes(store=store, key='attrs')
        assert 'foo' not in a
        assert 'bar' not in a
        eq(dict(), a.asdict())

        a['foo'] = 'bar'
        a['baz'] = 42
        assert 'attrs' in store
        assert isinstance(store['attrs'], binary_type)
        d = json.loads(text_type(store['attrs'], 'ascii'))
        eq(dict(foo='bar', baz=42), d)
Example #4
0
    def test_storage(self, store_from_dict):

        if store_from_dict:
            store = dict()
        else:
            store = KVStore(dict())
        a = Attributes(store=store, key='attrs')
        assert isinstance(a.store, KVStore)
        assert 'foo' not in a
        assert 'bar' not in a
        assert dict() == a.asdict()

        a['foo'] = 'bar'
        a['baz'] = 42
        assert 'attrs' in store
        assert isinstance(store['attrs'], bytes)
        d = json.loads(str(store['attrs'], 'ascii'))
        assert dict(foo='bar', baz=42) == d
Example #5
0
    def test_storage(self, zarr_version):

        store = _init_store(zarr_version)
        root = '.z' if zarr_version == 2 else meta_root
        attrs_key = root + 'attrs'
        a = Attributes(store=store, key=attrs_key)
        assert isinstance(a.store, KVStore)
        assert 'foo' not in a
        assert 'bar' not in a
        assert dict() == a.asdict()

        a['foo'] = 'bar'
        a['baz'] = 42
        assert attrs_key in store
        assert isinstance(store[attrs_key], bytes)
        d = json.loads(str(store[attrs_key], 'ascii'))
        if zarr_version == 3:
            d = d['attributes']
        assert dict(foo='bar', baz=42) == d