mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
More tests for sync status
This commit is contained in:
parent
be33fd3ed3
commit
1f8d1a0dc5
1 changed files with 14 additions and 5 deletions
|
|
@ -3,6 +3,7 @@ import pytest
|
|||
from hypothesis import assume, given
|
||||
import hypothesis.strategies as st
|
||||
|
||||
from vdirsyncer.sync.exceptions import IdentAlreadyExists
|
||||
from vdirsyncer.sync.status import SqliteStatus
|
||||
|
||||
|
||||
|
|
@ -13,7 +14,7 @@ def new_status(request):
|
|||
return request.param
|
||||
|
||||
|
||||
@given(status_dict=st.dictionaries(
|
||||
status_dict_strategy = st.dictionaries(
|
||||
st.text(),
|
||||
st.tuples(*(
|
||||
st.fixed_dictionaries({
|
||||
|
|
@ -22,13 +23,21 @@ def new_status(request):
|
|||
'etag': st.text()
|
||||
}) for _ in range(2)
|
||||
))
|
||||
))
|
||||
)
|
||||
|
||||
|
||||
@given(status_dict=status_dict_strategy)
|
||||
def test_legacy_status(new_status, status_dict):
|
||||
hrefs_a = {meta_a['href'] for meta_a, meta_b in status_dict.values()}
|
||||
hrefs_b = {meta_b['href'] for meta_a, meta_b in status_dict.values()}
|
||||
assume(len(hrefs_a) == len(status_dict))
|
||||
assume(len(hrefs_b) == len(status_dict))
|
||||
|
||||
assume(len(hrefs_a) == len(status_dict) == len(hrefs_b))
|
||||
status = new_status()
|
||||
status.load_legacy_status(status_dict)
|
||||
assert dict(status.to_legacy_status()) == status_dict
|
||||
|
||||
for ident, (meta_a, meta_b) in status_dict.items():
|
||||
ident_a, meta2_a = status.get_by_href_a(meta_a['href'])
|
||||
ident_b, meta2_b = status.get_by_href_b(meta_b['href'])
|
||||
assert meta2_a.to_status() == meta_a
|
||||
assert meta2_b.to_status() == meta_b
|
||||
assert ident_a == ident_b == ident
|
||||
|
|
|
|||
Loading…
Reference in a new issue