Пример #1
0
    def test_metadata_normalization(self, requires_metadata, s, value):
        x = s.get_meta('displayname')
        assert x == normalize_meta_value(x)

        if not getattr(self, 'dav_server', None):
            # ownCloud replaces "" with "unnamed"
            s.set_meta('displayname', value)
            assert s.get_meta('displayname') == normalize_meta_value(value)
Пример #2
0
    def test_metadata_normalization(self, requires_metadata, s, value):
        x = s.get_meta('displayname')
        assert x == normalize_meta_value(x)

        if not getattr(self, 'dav_server', None):
            # ownCloud replaces "" with "unnamed"
            s.set_meta('displayname', value)
            assert s.get_meta('displayname') == normalize_meta_value(value)
Пример #3
0
    status = {}
    a.set_meta('foo', 'bar')
    b.set_meta('foo', 'baz')

    metasync(a,
             b,
             status,
             keys=['foo'],
             conflict_resolution='a wins' if wins == 'a' else 'b wins')

    assert a.get_meta('foo') == b.get_meta('foo') == status['foo'] == (
        'bar' if wins == 'a' else 'baz')


keys = st.text(min_size=1).filter(lambda x: x.strip() == x)
values = st.text().filter(lambda x: normalize_meta_value(x) == x)
metadata = st.dictionaries(keys, values)


@given(a=metadata,
       b=metadata,
       status=metadata,
       keys=st.sets(keys),
       conflict_resolution=st.just('a wins') | st.just('b wins'))
@example(a={'0': '0'},
         b={},
         status={'0': '0'},
         keys={'0'},
         conflict_resolution='a wins')
@example(a={'0': '0'},
         b={'0': '1'},
Пример #4
0
    a = MemoryStorage()
    b = MemoryStorage()
    status = {}
    a.set_meta('foo', 'bar')
    b.set_meta('foo', 'baz')

    metasync(a, b, status, keys=['foo'],
             conflict_resolution='a wins' if wins == 'a' else 'b wins')

    assert a.get_meta('foo') == b.get_meta('foo') == status['foo'] == (
        'bar' if wins == 'a' else 'baz'
    )


keys = st.text(min_size=1).filter(lambda x: x.strip() == x)
values = st.text().filter(lambda x: normalize_meta_value(x) == x)
metadata = st.dictionaries(keys, values)


@given(
    a=metadata, b=metadata,
    status=metadata, keys=st.sets(keys),
    conflict_resolution=st.just('a wins') | st.just('b wins')
)
@example(a={u'0': u'0'}, b={}, status={u'0': u'0'}, keys={u'0'},
         conflict_resolution='a wins')
def test_fuzzing(a, b, status, keys, conflict_resolution):
    def _get_storage(m, instance_name):
        s = MemoryStorage(instance_name=instance_name)
        s.metadata = m
        return s
Пример #5
0
    def test_metadata_normalization(self, requires_metadata, s, value):
        x = s.get_meta('displayname')
        assert x == normalize_meta_value(x)

        s.set_meta('displayname', value)
        assert s.get_meta('displayname') == normalize_meta_value(value)