mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Module restructuring
This commit is contained in:
parent
83daa8698d
commit
76f794eef3
18 changed files with 41 additions and 43 deletions
|
|
@ -5,7 +5,7 @@ Test suite for vdirsyncer.
|
|||
|
||||
import hypothesis.strategies as st
|
||||
|
||||
from vdirsyncer.utils.vobject import normalize_item
|
||||
from vdirsyncer.vobject import normalize_item
|
||||
|
||||
|
||||
def blow_up(*a, **kw):
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ from hypothesis import given
|
|||
|
||||
import pytest
|
||||
|
||||
import vdirsyncer.exceptions as exceptions
|
||||
from vdirsyncer.storage.base import Item, normalize_meta_value
|
||||
from vdirsyncer import exceptions
|
||||
from vdirsyncer.storage.base import normalize_meta_value
|
||||
from vdirsyncer.vobject import Item
|
||||
|
||||
from .. import EVENT_TEMPLATE, TASK_TEMPLATE, VCARD_TEMPLATE, \
|
||||
assert_item_equals, normalize_item, printable_characters_strategy
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import requests.exceptions
|
|||
|
||||
from tests import assert_item_equals
|
||||
|
||||
import vdirsyncer.exceptions as exceptions
|
||||
from vdirsyncer.storage.base import Item
|
||||
from vdirsyncer import exceptions
|
||||
from vdirsyncer.vobject import Item
|
||||
|
||||
from .. import StorageTests, get_server_mixin
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import subprocess
|
|||
import pytest
|
||||
|
||||
from vdirsyncer.storage.filesystem import FilesystemStorage
|
||||
from vdirsyncer.utils.vobject import Item
|
||||
from vdirsyncer.vobject import Item
|
||||
|
||||
from . import StorageTests
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,7 @@ import pytest
|
|||
|
||||
import requests
|
||||
|
||||
from vdirsyncer import utils
|
||||
|
||||
# These modules might be uninitialized and unavailable if not explicitly
|
||||
# imported
|
||||
import vdirsyncer.utils.http # noqa
|
||||
from vdirsyncer import http, utils
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
|
@ -33,10 +29,10 @@ def test_request_ssl(httpsserver):
|
|||
httpsserver.serve_content('') # we need to serve something
|
||||
|
||||
with pytest.raises(requests.exceptions.SSLError) as excinfo:
|
||||
utils.http.request('GET', httpsserver.url)
|
||||
http.request('GET', httpsserver.url)
|
||||
assert 'certificate verify failed' in str(excinfo.value)
|
||||
|
||||
utils.http.request('GET', httpsserver.url, verify=False)
|
||||
http.request('GET', httpsserver.url, verify=False)
|
||||
|
||||
|
||||
def _fingerprints_broken():
|
||||
|
|
@ -54,15 +50,15 @@ def _fingerprints_broken():
|
|||
def test_request_ssl_fingerprints(httpsserver, fingerprint):
|
||||
httpsserver.serve_content('') # we need to serve something
|
||||
|
||||
utils.http.request('GET', httpsserver.url, verify=False,
|
||||
verify_fingerprint=fingerprint)
|
||||
http.request('GET', httpsserver.url, verify=False,
|
||||
verify_fingerprint=fingerprint)
|
||||
with pytest.raises(requests.exceptions.SSLError) as excinfo:
|
||||
utils.http.request('GET', httpsserver.url,
|
||||
verify_fingerprint=fingerprint)
|
||||
http.request('GET', httpsserver.url,
|
||||
verify_fingerprint=fingerprint)
|
||||
|
||||
with pytest.raises(requests.exceptions.SSLError) as excinfo:
|
||||
utils.http.request('GET', httpsserver.url, verify=False,
|
||||
verify_fingerprint=''.join(reversed(fingerprint)))
|
||||
http.request('GET', httpsserver.url, verify=False,
|
||||
verify_fingerprint=''.join(reversed(fingerprint)))
|
||||
assert 'Fingerprints did not match' in str(excinfo.value)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
|
||||
from vdirsyncer.cli.config import _resolve_conflict_via_command
|
||||
from vdirsyncer.utils.vobject import Item
|
||||
from vdirsyncer.vobject import Item
|
||||
|
||||
|
||||
def test_conflict_resolution_command():
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from tests import uid_strategy
|
|||
from vdirsyncer.repair import IrreparableItem, repair_item, repair_storage
|
||||
from vdirsyncer.storage.memory import MemoryStorage
|
||||
from vdirsyncer.utils import href_safe
|
||||
from vdirsyncer.utils.vobject import Item
|
||||
from vdirsyncer.vobject import Item
|
||||
|
||||
|
||||
@given(uid=uid_strategy)
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ import pytest
|
|||
|
||||
from tests import blow_up, uid_strategy
|
||||
|
||||
from vdirsyncer.storage.base import Item
|
||||
from vdirsyncer.storage.memory import MemoryStorage, _random_string
|
||||
from vdirsyncer.sync import BothReadOnly, IdentConflict, PartialSync, \
|
||||
StorageEmpty, SyncConflict, sync
|
||||
from vdirsyncer.vobject import Item
|
||||
|
||||
|
||||
def empty_storage(x):
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from tests import BARE_EVENT_TEMPLATE, EVENT_TEMPLATE, \
|
|||
EVENT_WITH_TIMEZONE_TEMPLATE, VCARD_TEMPLATE, normalize_item, \
|
||||
uid_strategy
|
||||
|
||||
import vdirsyncer.utils.vobject as vobject
|
||||
import vdirsyncer.vobject as vobject
|
||||
|
||||
|
||||
_simple_split = [
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ def _resolve_conflict_via_command(a, b, command, a_name, b_name,
|
|||
if _check_call is None:
|
||||
from subprocess import check_call as _check_call
|
||||
|
||||
from ..utils.vobject import Item
|
||||
from ..vobject import Item
|
||||
|
||||
dir = tempfile.mkdtemp(prefix='vdirsyncer-conflict.')
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import logging
|
|||
|
||||
import requests
|
||||
|
||||
from . import expand_path
|
||||
from .. import DOCS_HOME, exceptions
|
||||
from .utils import expand_path
|
||||
from . import DOCS_HOME, exceptions
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -5,7 +5,6 @@ import functools
|
|||
|
||||
from .. import exceptions
|
||||
from ..utils import uniq
|
||||
from ..utils.vobject import Item # noqa
|
||||
|
||||
|
||||
def mutating_storage_method(f):
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ from inspect import getfullargspec
|
|||
import requests
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from .base import Item, Storage, normalize_meta_value
|
||||
from .. import exceptions, utils
|
||||
from ..utils.http import HTTP_STORAGE_PARAMETERS, USERAGENT, prepare_auth, \
|
||||
from .base import Storage, normalize_meta_value
|
||||
from .. import exceptions, http, utils
|
||||
from ..http import HTTP_STORAGE_PARAMETERS, USERAGENT, prepare_auth, \
|
||||
prepare_client_cert, prepare_verify
|
||||
from ..vobject import Item
|
||||
|
||||
|
||||
dav_logger = logging.getLogger(__name__)
|
||||
|
|
@ -362,7 +363,7 @@ class DAVSession(object):
|
|||
|
||||
more = dict(self._settings)
|
||||
more.update(kwargs)
|
||||
return utils.http.request(method, url, session=self._session, **more)
|
||||
return http.request(method, url, session=self._session, **more)
|
||||
|
||||
def get_default_headers(self):
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@ import subprocess
|
|||
|
||||
from atomicwrites import atomic_write
|
||||
|
||||
from .base import Item, Storage, normalize_meta_value
|
||||
from .base import Storage, normalize_meta_value
|
||||
from .. import exceptions
|
||||
from ..utils import checkdir, expand_path, generate_href, get_etag_from_file
|
||||
from ..vobject import Item
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
import urllib.parse as urlparse
|
||||
|
||||
from .base import Item, Storage
|
||||
from .base import Storage
|
||||
from .. import exceptions
|
||||
from ..utils.http import HTTP_STORAGE_PARAMETERS, USERAGENT, prepare_auth, \
|
||||
from ..http import HTTP_STORAGE_PARAMETERS, USERAGENT, prepare_auth, \
|
||||
prepare_client_cert, prepare_verify, request
|
||||
from ..utils.vobject import split_collection
|
||||
from ..vobject import Item, split_collection
|
||||
|
||||
|
||||
class HttpStorage(Storage):
|
||||
|
|
|
|||
|
|
@ -11,10 +11,11 @@ from urllib.parse import quote as urlquote, urljoin
|
|||
|
||||
import click
|
||||
|
||||
from .base import Item, Storage, normalize_meta_value
|
||||
from .base import Storage, normalize_meta_value
|
||||
from .http import HTTP_STORAGE_PARAMETERS, prepare_client_cert, \
|
||||
prepare_verify
|
||||
from .. import exceptions, utils
|
||||
from .. import exceptions, utils, http
|
||||
from ..vobject import Item
|
||||
|
||||
REDIRECT_URI = 'https://vdirsyncer.5apps.com/'
|
||||
CLIENT_ID = 'https://vdirsyncer.5apps.com'
|
||||
|
|
@ -77,8 +78,7 @@ class Session(object):
|
|||
settings = dict(self._settings)
|
||||
settings.update(kwargs)
|
||||
|
||||
return utils.http.request(method, url,
|
||||
session=self._session, **settings)
|
||||
return http.request(method, url, session=self._session, **settings)
|
||||
|
||||
def _get_access_token(self):
|
||||
authorization_url, state = \
|
||||
|
|
@ -94,7 +94,7 @@ class Session(object):
|
|||
raise exceptions.UserError('Aborted!')
|
||||
|
||||
def _discover_endpoints(self, subpath):
|
||||
r = utils.http.request(
|
||||
r = http.request(
|
||||
'GET', 'https://{host}/.well-known/webfinger?resource=acct:{user}'
|
||||
.format(host=self.host, user=self.user),
|
||||
**self._settings
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ import os
|
|||
|
||||
from atomicwrites import atomic_write
|
||||
|
||||
from .base import Item, Storage
|
||||
from .base import Storage
|
||||
from .. import exceptions
|
||||
from ..utils import checkfile, expand_path
|
||||
from ..utils.vobject import join_collection, split_collection
|
||||
from ..vobject import Item, join_collection, split_collection
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import hashlib
|
||||
from itertools import chain, tee
|
||||
|
||||
from . import cached_property, uniq
|
||||
from .utils import cached_property, uniq
|
||||
|
||||
|
||||
IGNORE_PROPS = (
|
||||
Loading…
Reference in a new issue