diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py index fd15dfc..b1fc4c3 100644 --- a/tests/storage/__init__.py +++ b/tests/storage/__init__.py @@ -9,7 +9,7 @@ from vdirsyncer.storage.base import Item import vdirsyncer.exceptions as exceptions -from .. import assert_item_equals, normalize_item +from .. import assert_item_equals import random import pytest diff --git a/tests/storage/dav/_radicale.py b/tests/storage/dav/_radicale.py index 50fd6d3..5893683 100644 --- a/tests/storage/dav/_radicale.py +++ b/tests/storage/dav/_radicale.py @@ -15,7 +15,6 @@ import sys import os import urlparse -import shutil import pytest from werkzeug.test import Client @@ -75,8 +74,8 @@ def do_the_radicale_dance(tmpdir): radicale.config.set('rights', 'type', 'owner_only') radicale.config.set('auth', 'type', 'http') - import radicale.auth.http + def is_authenticated(user, password): assert user == 'bob' and password == 'bob' return True @@ -121,7 +120,6 @@ class ServerMixin(object): r.status_code = wr.status_code return r - monkeypatch.setattr('requests.adapters.HTTPAdapter.send', send) def get_storage_args(self, collection='test'): diff --git a/tests/storage/test_filesystem.py b/tests/storage/test_filesystem.py index bdd8be3..b2faf5f 100644 --- a/tests/storage/test_filesystem.py +++ b/tests/storage/test_filesystem.py @@ -44,6 +44,7 @@ class TestFilesystemStorage(StorageTests): def test_broken_data(self, tmpdir): s = self.storage_class(str(tmpdir), '.txt') + class BrokenItem(object): raw = b'Ц, Ш, Л, ж, Д, З, Ю' uid = 'jeezus' diff --git a/tests/storage/test_http.py b/tests/storage/test_http.py index aa9e6d4..d874503 100644 --- a/tests/storage/test_http.py +++ b/tests/storage/test_http.py @@ -7,9 +7,8 @@ :license: MIT, see LICENSE for more details. ''' -from .. import assert_item_equals from textwrap import dedent -from vdirsyncer.storage.http import HttpStorage, Item +from vdirsyncer.storage.http import HttpStorage from requests import Response diff --git a/tests/test_cli.py b/tests/test_cli.py index 4cb20e6..69faf96 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -9,7 +9,7 @@ from textwrap import dedent import vdirsyncer.cli as cli -import vdirsyncer.exceptions as exceptions + def test_load_config(tmpdir, monkeypatch): f = tmpdir.join('test.cfg') @@ -54,6 +54,7 @@ def test_load_config(tmpdir, monkeypatch): assert errors[0].startswith('Unknown section') assert 'bogus' in errors[0] + def test_storage_instance_from_config(monkeypatch): def lol(**kw): assert kw == {'foo': 'bar', 'baz': 1} diff --git a/tests/test_utils.py b/tests/test_utils.py index a154e0d..b7f6c9c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -35,6 +35,9 @@ def test_parse_options(): assert a == expected for key in a: + # Yes, we want a very strong typecheck here, because we actually have + # to differentiate between bool and int, and in Python 2, bool is a + # subclass of int. assert type(a[key]) is type(expected[key]) diff --git a/vdirsyncer/storage/base.py b/vdirsyncer/storage/base.py index 69e5f58..c342898 100644 --- a/vdirsyncer/storage/base.py +++ b/vdirsyncer/storage/base.py @@ -35,8 +35,8 @@ class Storage(object): - HREF: String; Per-storage identifier of item, might be UID. The reason items aren't just referenced by their UID is because the CalDAV and CardDAV specifications make this imperformant to implement. - - ETAG: String; Checksum of item, or something similar that changes when the - item does. + - ETAG: String; Checksum of item, or something similar that changes when + the item does. Strings can be either unicode strings or bytestrings. If bytestrings, an ASCII encoding is assumed. diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index 02180de..1867d48 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -11,7 +11,7 @@ from .base import Storage, Item from .http import prepare_auth, prepare_verify, USERAGENT from .. import exceptions from .. import log -from ..utils import request +from ..utils import request, get_password import requests import datetime import urlparse diff --git a/vdirsyncer/storage/http.py b/vdirsyncer/storage/http.py index e1e3629..517fcb3 100644 --- a/vdirsyncer/storage/http.py +++ b/vdirsyncer/storage/http.py @@ -8,7 +8,6 @@ :license: MIT, see LICENSE for more details. ''' -import requests import urlparse import hashlib from .base import Storage, Item