summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2017-04-29 16:40:55 +0200
committerdrebs <drebs@leap.se>2017-05-01 21:10:18 +0200
commita2a41830f72ae014d3b4dba591c6bfc85ffeb062 (patch)
treeb853c88c3830df52c6f0a2b544ce65b02927816e
parenta9580838817c2fbc883253f6df0edc29fcd4c947 (diff)
[refactor] create client _database module
-rw-r--r--client/src/leap/soledad/client/_database/__init__.py0
-rw-r--r--client/src/leap/soledad/client/_database/adbapi.py (renamed from client/src/leap/soledad/client/adbapi.py)9
-rw-r--r--client/src/leap/soledad/client/_database/blobs.py (renamed from client/src/leap/soledad/client/_blobs.py)35
-rw-r--r--client/src/leap/soledad/client/_database/dbschema.sql (renamed from common/src/leap/soledad/common/l2db/backends/dbschema.sql)0
-rw-r--r--client/src/leap/soledad/client/_database/pragmas.py (renamed from client/src/leap/soledad/client/pragmas.py)0
-rw-r--r--client/src/leap/soledad/client/_database/sqlcipher.py (renamed from client/src/leap/soledad/client/sqlcipher.py)23
-rw-r--r--client/src/leap/soledad/client/_database/sqlite.py (renamed from common/src/leap/soledad/common/l2db/backends/sqlite_backend.py)0
-rw-r--r--client/src/leap/soledad/client/api.py20
-rw-r--r--client/src/leap/soledad/client/examples/benchmarks/measure_index_times.py2
-rw-r--r--client/src/leap/soledad/client/examples/benchmarks/measure_index_times_custom_docid.py2
-rw-r--r--client/src/leap/soledad/client/examples/use_adbapi.py2
-rw-r--r--client/src/leap/soledad/client/http_target/fetch.py2
-rw-r--r--common/src/leap/soledad/common/l2db/__init__.py4
-rw-r--r--common/src/leap/soledad/common/l2db/remote/server_state.py14
-rw-r--r--testing/test_soledad/u1db_tests/__init__.py7
-rw-r--r--testing/test_soledad/u1db_tests/test_open.py11
-rw-r--r--testing/test_soledad/util.py4
-rw-r--r--testing/tests/blobs/test_blobs.py10
-rw-r--r--testing/tests/blobs/test_local_backend.py2
-rw-r--r--testing/tests/client/test_aux_methods.py2
-rw-r--r--testing/tests/server/test_blobs_server.py4
-rw-r--r--testing/tests/sqlcipher/test_async.py6
-rw-r--r--testing/tests/sqlcipher/test_backend.py9
-rw-r--r--testing/tests/sync/test_sync_target.py6
24 files changed, 85 insertions, 89 deletions
diff --git a/client/src/leap/soledad/client/_database/__init__.py b/client/src/leap/soledad/client/_database/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/client/src/leap/soledad/client/_database/__init__.py
diff --git a/client/src/leap/soledad/client/adbapi.py b/client/src/leap/soledad/client/_database/adbapi.py
index b002055e..5c28d108 100644
--- a/client/src/leap/soledad/client/adbapi.py
+++ b/client/src/leap/soledad/client/_database/adbapi.py
@@ -30,8 +30,9 @@ from zope.proxy import ProxyBase, setProxiedObject
from leap.soledad.common.log import getLogger
from leap.soledad.common.errors import DatabaseAccessError
-from leap.soledad.client import sqlcipher as soledad_sqlcipher
-from leap.soledad.client.pragmas import set_init_pragmas
+
+from . import sqlcipher
+from . import pragmas
if sys.version_info[0] < 3:
from pysqlcipher import dbapi2
@@ -73,7 +74,7 @@ def getConnectionPool(opts, openfun=None, driver="pysqlcipher"):
:rtype: U1DBConnectionPool
"""
if openfun is None and driver == "pysqlcipher":
- openfun = partial(set_init_pragmas, opts=opts)
+ openfun = partial(pragmas.set_init_pragmas, opts=opts)
return U1DBConnectionPool(
opts,
# the following params are relayed "as is" to twisted's
@@ -87,7 +88,7 @@ class U1DBConnection(adbapi.Connection):
A wrapper for a U1DB connection instance.
"""
- u1db_wrapper = soledad_sqlcipher.SoledadSQLCipherWrapper
+ u1db_wrapper = sqlcipher.SoledadSQLCipherWrapper
"""
The U1DB wrapper to use.
"""
diff --git a/client/src/leap/soledad/client/_blobs.py b/client/src/leap/soledad/client/_database/blobs.py
index 90007427..91914380 100644
--- a/client/src/leap/soledad/client/_blobs.py
+++ b/client/src/leap/soledad/client/_database/blobs.py
@@ -22,7 +22,6 @@ from urlparse import urljoin
import errno
import os
-import uuid
import base64
from io import BytesIO
@@ -35,13 +34,18 @@ from twisted.web.client import FileBodyProducer
import treq
-from leap.soledad.client.sqlcipher import SQLCipherOptions
-from leap.soledad.client import pragmas
-from leap.soledad.client._pipes import TruncatedTailPipe, PreamblePipe
from leap.soledad.common.errors import SoledadError
-from _crypto import DocInfo, BlobEncryptor, BlobDecryptor
-from _http import HTTPClient
+from .._document import BlobDoc
+from .._crypto import DocInfo
+from .._crypto import BlobEncryptor
+from .._crypto import BlobDecryptor
+from .._http import HTTPClient
+from .._pipes import TruncatedTailPipe
+from .._pipes import PreamblePipe
+
+from . import pragmas
+from . import sqlcipher
logger = Logger()
@@ -293,7 +297,7 @@ class SQLiteBlobBackend(object):
if not key:
raise ValueError('key cannot be None')
backend = 'pysqlcipher.dbapi2'
- opts = SQLCipherOptions('/tmp/ignored', key)
+ opts = sqlcipher.SQLCipherOptions('/tmp/ignored', key)
pragmafun = partial(pragmas.set_init_pragmas, opts=opts)
openfun = _sqlcipherInitFactory(pragmafun)
@@ -360,20 +364,6 @@ def _sqlcipherInitFactory(fun):
return _initialize
-class BlobDoc(object):
-
- # TODO probably not needed, but convenient for testing for now.
-
- def __init__(self, content, blob_id):
-
- self.blob_id = blob_id
- self.is_blob = True
- self.blob_fd = content
- if blob_id is None:
- blob_id = uuid.uuid4().get_hex()
- self.blob_id = blob_id
-
-
#
# testing facilities
#
@@ -439,8 +429,7 @@ def testit(reactor):
# TODO convert these into proper unittests
def _manager():
- if not os.path.isdir(args.path):
- mkdir_p(args.path)
+ mkdir_p(os.path.dirname(args.path))
manager = BlobManager(
args.path, args.url,
'A' * 32, args.secret,
diff --git a/common/src/leap/soledad/common/l2db/backends/dbschema.sql b/client/src/leap/soledad/client/_database/dbschema.sql
index ae027fc5..ae027fc5 100644
--- a/common/src/leap/soledad/common/l2db/backends/dbschema.sql
+++ b/client/src/leap/soledad/client/_database/dbschema.sql
diff --git a/client/src/leap/soledad/client/pragmas.py b/client/src/leap/soledad/client/_database/pragmas.py
index 870ed63e..870ed63e 100644
--- a/client/src/leap/soledad/client/pragmas.py
+++ b/client/src/leap/soledad/client/_database/pragmas.py
diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/_database/sqlcipher.py
index 14fecd3b..d22017bd 100644
--- a/client/src/leap/soledad/client/sqlcipher.py
+++ b/client/src/leap/soledad/client/_database/sqlcipher.py
@@ -52,13 +52,14 @@ from twisted.enterprise import adbapi
from leap.soledad.common.log import getLogger
from leap.soledad.common.l2db import errors as u1db_errors
-from leap.soledad.common.l2db.backends import sqlite_backend
from leap.soledad.common.errors import DatabaseAccessError
from leap.soledad.client.http_target import SoledadHTTPSyncTarget
from leap.soledad.client.sync import SoledadSynchronizer
-from leap.soledad.client import pragmas
-from leap.soledad.client._document import Document
+
+from .._document import Document
+from . import sqlite
+from . import pragmas
if sys.version_info[0] < 3:
from pysqlcipher import dbapi2 as sqlcipher_dbapi2
@@ -68,8 +69,8 @@ else:
logger = getLogger(__name__)
-# Monkey-patch u1db.backends.sqlite_backend with pysqlcipher.dbapi2
-sqlite_backend.dbapi2 = sqlcipher_dbapi2
+# Monkey-patch u1db.backends.sqlite with pysqlcipher.dbapi2
+sqlite.dbapi2 = sqlcipher_dbapi2
# we may want to collect statistics from the sync process
@@ -192,7 +193,7 @@ class SQLCipherOptions(object):
# The SQLCipher database
#
-class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
+class SQLCipherDatabase(sqlite.SQLitePartialExpandDatabase):
"""
A U1DB implementation that uses SQLCipher as its persistence layer.
"""
@@ -340,7 +341,7 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
:param doc: The new version of the document.
:type doc: u1db.Document
"""
- sqlite_backend.SQLitePartialExpandDatabase._put_and_update_indexes(
+ sqlite.SQLitePartialExpandDatabase._put_and_update_indexes(
self, old_doc, doc)
c = self._db_handle.cursor()
c.execute('UPDATE document SET syncable=? WHERE doc_id=?',
@@ -360,7 +361,7 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase):
:return: a Document object.
:type: u1db.Document
"""
- doc = sqlite_backend.SQLitePartialExpandDatabase._get_doc(
+ doc = sqlite.SQLitePartialExpandDatabase._get_doc(
self, doc_id, check_for_conflicts)
if doc:
c = self._db_handle.cursor()
@@ -504,7 +505,7 @@ class SQLCipherU1DBSync(SQLCipherDatabase):
return self._get_generation()
-class U1DBSQLiteBackend(sqlite_backend.SQLitePartialExpandDatabase):
+class U1DBSQLiteBackend(sqlite.SQLitePartialExpandDatabase):
"""
A very simple wrapper for u1db around sqlcipher backend.
@@ -561,7 +562,7 @@ def _assert_db_is_encrypted(opts):
# If the regular backend succeeds, then we need to stop because
# the database was not properly initialized.
try:
- sqlite_backend.SQLitePartialExpandDatabase(opts.path)
+ sqlite.SQLitePartialExpandDatabase(opts.path)
except sqlcipher_dbapi2.DatabaseError:
# assert that we can access it using SQLCipher with the given
# key
@@ -592,7 +593,7 @@ def doc_factory(doc_id=None, rev=None, json='{}', has_conflicts=False,
has_conflicts=has_conflicts, syncable=syncable)
-sqlite_backend.SQLiteDatabase.register_implementation(SQLCipherDatabase)
+sqlite.SQLiteDatabase.register_implementation(SQLCipherDatabase)
#
diff --git a/common/src/leap/soledad/common/l2db/backends/sqlite_backend.py b/client/src/leap/soledad/client/_database/sqlite.py
index 4f7b1259..4f7b1259 100644
--- a/common/src/leap/soledad/common/l2db/backends/sqlite_backend.py
+++ b/client/src/leap/soledad/client/_database/sqlite.py
diff --git a/client/src/leap/soledad/client/api.py b/client/src/leap/soledad/client/api.py
index fee9e160..3dd99227 100644
--- a/client/src/leap/soledad/client/api.py
+++ b/client/src/leap/soledad/client/api.py
@@ -51,14 +51,14 @@ from leap.soledad.common.l2db.remote import http_client
from leap.soledad.common.l2db.remote.ssl_match_hostname import match_hostname
from leap.soledad.common.errors import DatabaseAccessError
-from leap.soledad.client import adbapi
-from leap.soledad.client import events as soledad_events
-from leap.soledad.client import interfaces as soledad_interfaces
-from leap.soledad.client import sqlcipher
-from leap.soledad.client._recovery_code import RecoveryCode
-from leap.soledad.client._secrets import Secrets
-from leap.soledad.client._crypto import SoledadCrypto
-from ._blobs import BlobManager
+from . import events as soledad_events
+from . import interfaces as soledad_interfaces
+from ._crypto import SoledadCrypto
+from ._database import adbapi
+from ._database import blobs
+from ._database import sqlcipher
+from ._recovery_code import RecoveryCode
+from ._secrets import Secrets
logger = getLogger(__name__)
@@ -268,8 +268,8 @@ class Soledad(object):
path = os.path.join(os.path.dirname(self._local_db_path), 'blobs')
url = urlparse.urljoin(self.server_url, 'blobs/%s' % uuid)
key = self._secrets.local_key
- self.blobmanager = BlobManager(path, url, key, self.uuid, self.token,
- SOLEDAD_CERT)
+ self.blobmanager = blobs.BlobManager(path, url, key, self.uuid,
+ self.token, SOLEDAD_CERT)
#
# Closing methods
diff --git a/client/src/leap/soledad/client/examples/benchmarks/measure_index_times.py b/client/src/leap/soledad/client/examples/benchmarks/measure_index_times.py
index 92bc85d6..276b1200 100644
--- a/client/src/leap/soledad/client/examples/benchmarks/measure_index_times.py
+++ b/client/src/leap/soledad/client/examples/benchmarks/measure_index_times.py
@@ -28,7 +28,7 @@ from twisted.internet import defer, reactor
from leap.soledad.common import l2db
from leap.soledad.client import adbapi
-from leap.soledad.client.sqlcipher import SQLCipherOptions
+from leap.soledad.client._database.sqlcipher import SQLCipherOptions
folder = os.environ.get("TMPDIR", "tmp")
diff --git a/client/src/leap/soledad/client/examples/benchmarks/measure_index_times_custom_docid.py b/client/src/leap/soledad/client/examples/benchmarks/measure_index_times_custom_docid.py
index 429566c7..d288582b 100644
--- a/client/src/leap/soledad/client/examples/benchmarks/measure_index_times_custom_docid.py
+++ b/client/src/leap/soledad/client/examples/benchmarks/measure_index_times_custom_docid.py
@@ -27,7 +27,7 @@ import sys
from twisted.internet import defer, reactor
from leap.soledad.client import adbapi
-from leap.soledad.client.sqlcipher import SQLCipherOptions
+from leap.soledad.client._database.sqlcipher import SQLCipherOptions
from leap.soledad.common import l2db
diff --git a/client/src/leap/soledad/client/examples/use_adbapi.py b/client/src/leap/soledad/client/examples/use_adbapi.py
index 39301b41..25b32307 100644
--- a/client/src/leap/soledad/client/examples/use_adbapi.py
+++ b/client/src/leap/soledad/client/examples/use_adbapi.py
@@ -24,7 +24,7 @@ import os
from twisted.internet import defer, reactor
from leap.soledad.client import adbapi
-from leap.soledad.client.sqlcipher import SQLCipherOptions
+from leap.soledad.client._database.sqlcipher import SQLCipherOptions
from leap.soledad.common import l2db
diff --git a/client/src/leap/soledad/client/http_target/fetch.py b/client/src/leap/soledad/client/http_target/fetch.py
index c85c5bab..9d456830 100644
--- a/client/src/leap/soledad/client/http_target/fetch.py
+++ b/client/src/leap/soledad/client/http_target/fetch.py
@@ -23,10 +23,10 @@ from leap.soledad.client.events import emit_async
from leap.soledad.client.http_target.support import RequestBody
from leap.soledad.common.log import getLogger
from leap.soledad.client._crypto import is_symmetrically_encrypted
-from leap.soledad.common.document import Document
from leap.soledad.common.l2db import errors
from leap.soledad.client import crypto as old_crypto
+from .._document import Document
from . import fetch_protocol
logger = getLogger(__name__)
diff --git a/common/src/leap/soledad/common/l2db/__init__.py b/common/src/leap/soledad/common/l2db/__init__.py
index 568897c4..ebbf546a 100644
--- a/common/src/leap/soledad/common/l2db/__init__.py
+++ b/common/src/leap/soledad/common/l2db/__init__.py
@@ -37,8 +37,8 @@ def open(path, create, document_factory=None):
parameters as Document.__init__.
:return: An instance of Database.
"""
- from leap.soledad.common.l2db.backends import sqlite_backend
- return sqlite_backend.SQLiteDatabase.open_database(
+ from leap.soledad.client._database import sqlite
+ return sqlite.SQLiteDatabase.open_database(
path, create=create, document_factory=document_factory)
diff --git a/common/src/leap/soledad/common/l2db/remote/server_state.py b/common/src/leap/soledad/common/l2db/remote/server_state.py
index e20b4679..89ac5742 100644
--- a/common/src/leap/soledad/common/l2db/remote/server_state.py
+++ b/common/src/leap/soledad/common/l2db/remote/server_state.py
@@ -42,10 +42,9 @@ class ServerState(object):
def open_database(self, path):
"""Open a database at the given location."""
- from u1db.backends import sqlite_backend
+ from leap.soledad.client._database import sqlite
full_path = self._relpath(path)
- return sqlite_backend.SQLiteDatabase.open_database(full_path,
- create=False)
+ return sqlite.SQLiteDatabase.open_database(full_path, create=False)
def check_database(self, path):
"""Check if the database at the given location exists.
@@ -57,14 +56,13 @@ class ServerState(object):
def ensure_database(self, path):
"""Ensure database at the given location."""
- from u1db.backends import sqlite_backend
+ from leap.soledad.client._database import sqlite
full_path = self._relpath(path)
- db = sqlite_backend.SQLiteDatabase.open_database(full_path,
- create=True)
+ db = sqlite.SQLiteDatabase.open_database(full_path, create=True)
return db, db._replica_uid
def delete_database(self, path):
"""Delete database at the given location."""
- from u1db.backends import sqlite_backend
+ from leap.soledad.client._database import sqlite
full_path = self._relpath(path)
- sqlite_backend.SQLiteDatabase.delete_database(full_path)
+ sqlite.SQLiteDatabase.delete_database(full_path)
diff --git a/testing/test_soledad/u1db_tests/__init__.py b/testing/test_soledad/u1db_tests/__init__.py
index 1575b859..ccbb6ca6 100644
--- a/testing/test_soledad/u1db_tests/__init__.py
+++ b/testing/test_soledad/u1db_tests/__init__.py
@@ -37,11 +37,12 @@ from twisted.internet import reactor
from leap.soledad.common.l2db import errors
from leap.soledad.common.l2db import Document
from leap.soledad.common.l2db.backends import inmemory
-from leap.soledad.common.l2db.backends import sqlite_backend
from leap.soledad.common.l2db.remote import server_state
from leap.soledad.common.l2db.remote import http_app
from leap.soledad.common.l2db.remote import http_target
+from leap.soledad.client._database import sqlite
+
if sys.version_info[0] < 3:
from pysqlcipher import dbapi2
else:
@@ -140,7 +141,7 @@ def copy_memory_database_for_test(test, db):
def make_sqlite_partial_expanded_for_test(test, replica_uid):
- db = sqlite_backend.SQLitePartialExpandDatabase(':memory:')
+ db = sqlite.SQLitePartialExpandDatabase(':memory:')
db._set_replica_uid(replica_uid)
return db
@@ -151,7 +152,7 @@ def copy_sqlite_partial_expanded_for_test(test, db):
# CORRECTLY DETECT IT HAPPENING SO THAT WE CAN RAISE ERRORS RATHER THAN
# CORRUPT USER DATA. USE SYNC INSTEAD, OR WE WILL SEND NINJA TO YOUR
# HOUSE.
- new_db = sqlite_backend.SQLitePartialExpandDatabase(':memory:')
+ new_db = sqlite.SQLitePartialExpandDatabase(':memory:')
tmpfile = StringIO()
for line in db._db_handle.iterdump():
if 'sqlite_sequence' not in line: # work around bug in iterdump
diff --git a/testing/test_soledad/u1db_tests/test_open.py b/testing/test_soledad/u1db_tests/test_open.py
index b572fba0..eaaee72f 100644
--- a/testing/test_soledad/u1db_tests/test_open.py
+++ b/testing/test_soledad/u1db_tests/test_open.py
@@ -27,7 +27,8 @@ from test_soledad.u1db_tests.test_backends import TestAlternativeDocument
from leap.soledad.common.l2db import errors
from leap.soledad.common.l2db import open as u1db_open
-from leap.soledad.common.l2db.backends import sqlite_backend
+
+from leap.soledad.client._database import sqlite
@skip("Skiping tests imported from U1DB.")
@@ -47,7 +48,7 @@ class TestU1DBOpen(tests.TestCase):
db = u1db_open(self.db_path, create=True)
self.addCleanup(db.close)
self.assertTrue(os.path.exists(self.db_path))
- self.assertIsInstance(db, sqlite_backend.SQLiteDatabase)
+ self.assertIsInstance(db, sqlite.SQLiteDatabase)
def test_open_with_factory(self):
db = u1db_open(self.db_path, create=True,
@@ -56,7 +57,7 @@ class TestU1DBOpen(tests.TestCase):
self.assertEqual(TestAlternativeDocument, db._factory)
def test_open_existing(self):
- db = sqlite_backend.SQLitePartialExpandDatabase(self.db_path)
+ db = sqlite.SQLitePartialExpandDatabase(self.db_path)
self.addCleanup(db.close)
doc = db.create_doc_from_json(tests.simple_doc)
# Even though create=True, we shouldn't wipe the db
@@ -66,8 +67,8 @@ class TestU1DBOpen(tests.TestCase):
self.assertEqual(doc, doc2)
def test_open_existing_no_create(self):
- db = sqlite_backend.SQLitePartialExpandDatabase(self.db_path)
+ db = sqlite.SQLitePartialExpandDatabase(self.db_path)
self.addCleanup(db.close)
db2 = u1db_open(self.db_path, create=False)
self.addCleanup(db2.close)
- self.assertIsInstance(db2, sqlite_backend.SQLitePartialExpandDatabase)
+ self.assertIsInstance(db2, sqlite.SQLitePartialExpandDatabase)
diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py
index 6ffb60b6..0335d544 100644
--- a/testing/test_soledad/util.py
+++ b/testing/test_soledad/util.py
@@ -46,9 +46,9 @@ from leap.soledad.common.couch.state import CouchServerState
from leap.soledad.client import Soledad
from leap.soledad.client import http_target
from leap.soledad.client import auth
-from leap.soledad.client.sqlcipher import SQLCipherDatabase
-from leap.soledad.client.sqlcipher import SQLCipherOptions
from leap.soledad.client._crypto import is_symmetrically_encrypted
+from leap.soledad.client._database.sqlcipher import SQLCipherDatabase
+from leap.soledad.client._database.sqlcipher import SQLCipherOptions
from leap.soledad.server import SoledadApp
diff --git a/testing/tests/blobs/test_blobs.py b/testing/tests/blobs/test_blobs.py
index c99cc572..9a0feb61 100644
--- a/testing/tests/blobs/test_blobs.py
+++ b/testing/tests/blobs/test_blobs.py
@@ -17,12 +17,16 @@
"""
Tests for blobs handling.
"""
+from io import BytesIO
+from mock import Mock
+
from twisted.trial import unittest
from twisted.internet import defer
-from leap.soledad.client._blobs import DecrypterBuffer, BlobManager, FIXED_REV
+
+from leap.soledad.client._database.blobs import DecrypterBuffer
+from leap.soledad.client._database.blobs import BlobManager
+from leap.soledad.client._database.blobs import FIXED_REV
from leap.soledad.client import _crypto
-from io import BytesIO
-from mock import Mock
class BlobTestCase(unittest.TestCase):
diff --git a/testing/tests/blobs/test_local_backend.py b/testing/tests/blobs/test_local_backend.py
index 5caa7463..202d0611 100644
--- a/testing/tests/blobs/test_local_backend.py
+++ b/testing/tests/blobs/test_local_backend.py
@@ -19,7 +19,7 @@ Tests for sqlcipher backend on blobs client.
"""
from twisted.trial import unittest
from twisted.internet import defer
-from leap.soledad.client._blobs import BlobManager, BlobDoc, FIXED_REV
+from leap.soledad.client._database.blobs import BlobManager, BlobDoc, FIXED_REV
from io import BytesIO
from mock import Mock
import pytest
diff --git a/testing/tests/client/test_aux_methods.py b/testing/tests/client/test_aux_methods.py
index 729aa28a..da33255c 100644
--- a/testing/tests/client/test_aux_methods.py
+++ b/testing/tests/client/test_aux_methods.py
@@ -22,7 +22,7 @@ import os
from pytest import inlineCallbacks
from leap.soledad.client import Soledad
-from leap.soledad.client.adbapi import U1DBConnectionPool
+from leap.soledad.client._database.adbapi import U1DBConnectionPool
from leap.soledad.client._secrets.util import SecretsError
from test_soledad.util import BaseSoledadTest
diff --git a/testing/tests/server/test_blobs_server.py b/testing/tests/server/test_blobs_server.py
index 2e5af01f..cd39833f 100644
--- a/testing/tests/server/test_blobs_server.py
+++ b/testing/tests/server/test_blobs_server.py
@@ -24,8 +24,10 @@ from twisted.web.server import Site
from twisted.internet import reactor
from twisted.internet import defer
from treq._utils import set_global_pool
+
from leap.soledad.server import _blobs as server_blobs
-from leap.soledad.client._blobs import BlobManager, BlobAlreadyExistsError
+from leap.soledad.client._database.blobs import BlobManager
+from leap.soledad.client._database.blobs import BlobAlreadyExistsError
class BlobServerTestCase(unittest.TestCase):
diff --git a/testing/tests/sqlcipher/test_async.py b/testing/tests/sqlcipher/test_async.py
index 42c315fe..dac6c6b9 100644
--- a/testing/tests/sqlcipher/test_async.py
+++ b/testing/tests/sqlcipher/test_async.py
@@ -20,8 +20,8 @@ import hashlib
from twisted.internet import defer
from test_soledad.util import BaseSoledadTest
-from leap.soledad.client import adbapi
-from leap.soledad.client.sqlcipher import SQLCipherOptions
+from leap.soledad.client._database import adbapi
+from leap.soledad.client._database import sqlcipher
class ASyncSQLCipherRetryTestCase(BaseSoledadTest):
@@ -42,7 +42,7 @@ class ASyncSQLCipherRetryTestCase(BaseSoledadTest):
def _get_dbpool(self):
tmpdb = os.path.join(self.tempdir, "test.soledad")
- opts = SQLCipherOptions(tmpdb, "secret", create=True)
+ opts = sqlcipher.SQLCipherOptions(tmpdb, "secret", create=True)
return adbapi.getConnectionPool(opts)
def _get_sample(self):
diff --git a/testing/tests/sqlcipher/test_backend.py b/testing/tests/sqlcipher/test_backend.py
index 6e9595db..4f614fb3 100644
--- a/testing/tests/sqlcipher/test_backend.py
+++ b/testing/tests/sqlcipher/test_backend.py
@@ -26,14 +26,13 @@ import sys
# l2db stuff.
from leap.soledad.common.l2db import errors
from leap.soledad.common.l2db import query_parser
-from leap.soledad.common.l2db.backends.sqlite_backend \
- import SQLitePartialExpandDatabase
# soledad stuff.
from leap.soledad.common.document import SoledadDocument
-from leap.soledad.client.sqlcipher import SQLCipherDatabase
-from leap.soledad.client.sqlcipher import SQLCipherOptions
-from leap.soledad.client.sqlcipher import DatabaseIsNotEncrypted
+from leap.soledad.client._database.sqlite import SQLitePartialExpandDatabase
+from leap.soledad.client._database.sqlcipher import SQLCipherDatabase
+from leap.soledad.client._database.sqlcipher import SQLCipherOptions
+from leap.soledad.client._database.sqlcipher import DatabaseIsNotEncrypted
# u1db tests stuff.
from test_soledad import u1db_tests as tests
diff --git a/testing/tests/sync/test_sync_target.py b/testing/tests/sync/test_sync_target.py
index a54a02ee..e1bd7de1 100644
--- a/testing/tests/sync/test_sync_target.py
+++ b/testing/tests/sync/test_sync_target.py
@@ -32,9 +32,9 @@ from twisted.internet import defer
from leap.soledad.client import http_target as target
from leap.soledad.client.http_target.fetch_protocol import DocStreamReceiver
-from leap.soledad.client.sqlcipher import SQLCipherU1DBSync
-from leap.soledad.client.sqlcipher import SQLCipherOptions
-from leap.soledad.client.sqlcipher import SQLCipherDatabase
+from leap.soledad.client._database.sqlcipher import SQLCipherU1DBSync
+from leap.soledad.client._database.sqlcipher import SQLCipherOptions
+from leap.soledad.client._database.sqlcipher import SQLCipherDatabase
from leap.soledad.client import _crypto
from leap.soledad.common import l2db