summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-01-22 09:51:08 -0200
committerdrebs <drebs@leap.se>2013-01-22 09:51:38 -0200
commit9a487e87aceddbf656f14961356c74cb7a1de146 (patch)
treec0fdf4b757001e8781061763fbcd7e19e92abbff /tests
parenta2ab7b2b9ca71f7c9fc99f6ddb614d6061c17b81 (diff)
Cleanup tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_couch.py54
-rw-r--r--tests/test_encrypted.py5
-rw-r--r--tests/test_leap_backend.py64
-rw-r--r--tests/test_logs.py1
-rw-r--r--tests/test_sqlcipher.py51
5 files changed, 51 insertions, 124 deletions
diff --git a/tests/test_couch.py b/tests/test_couch.py
index 2bdc07b3..6b5875b8 100644
--- a/tests/test_couch.py
+++ b/tests/test_couch.py
@@ -4,42 +4,16 @@ For these tests to run, a couch server has to be running on (default) port
5984.
"""
+import copy
+from leap.soledad.backends import couch
+from leap.soledad.tests import u1db_tests as tests
+from leap.soledad.tests.u1db_tests import test_backends
+from leap.soledad.tests.u1db_tests import test_sync
try:
import simplejson as json
except ImportError:
import json # noqa
-import os
-import sys
-import copy
-import testtools
-import testscenarios
-from leap.soledad.backends import couch
-from leap.soledad.tests import u1db_tests as tests
-from leap.soledad.tests.u1db_tests.test_backends import (
- TestAlternativeDocument,
- AllDatabaseTests,
- LocalDatabaseTests,
- LocalDatabaseValidateGenNTransIdTests,
- LocalDatabaseValidateSourceGenTests,
- LocalDatabaseWithConflictsTests,
- DatabaseIndexTests,
-)
-from leap.soledad.tests.u1db_tests.test_sync import (
- target_scenarios,
- _make_local_db_and_target,
- _make_local_db_and_http_target,
- _make_local_db_and_oauth_http_target,
- DatabaseSyncTargetTests,
- DatabaseSyncTests,
- sync_via_synchronizer,
-)
-from leap.soledad.tests.u1db_tests.test_remote_sync_target import (
- make_http_app,
- make_oauth_http_app,
-)
-
-
#-----------------------------------------------------------------------------
# The following tests come from `u1db.tests.test_common_backend`.
#-----------------------------------------------------------------------------
@@ -83,7 +57,7 @@ COUCH_SCENARIOS = [
]
-class CouchTests(AllDatabaseTests):
+class CouchTests(test_backends.AllDatabaseTests):
scenarios = COUCH_SCENARIOS
@@ -92,7 +66,7 @@ class CouchTests(AllDatabaseTests):
super(CouchTests, self).tearDown()
-class CouchDatabaseTests(LocalDatabaseTests):
+class CouchDatabaseTests(test_backends.LocalDatabaseTests):
scenarios = COUCH_SCENARIOS
@@ -101,7 +75,7 @@ class CouchDatabaseTests(LocalDatabaseTests):
super(CouchDatabaseTests, self).tearDown()
-class CouchValidateGenNTransIdTests(LocalDatabaseValidateGenNTransIdTests):
+class CouchValidateGenNTransIdTests(test_backends.LocalDatabaseValidateGenNTransIdTests):
scenarios = COUCH_SCENARIOS
@@ -110,7 +84,7 @@ class CouchValidateGenNTransIdTests(LocalDatabaseValidateGenNTransIdTests):
super(CouchValidateGenNTransIdTests, self).tearDown()
-class CouchValidateSourceGenTests(LocalDatabaseValidateSourceGenTests):
+class CouchValidateSourceGenTests(test_backends.LocalDatabaseValidateSourceGenTests):
scenarios = COUCH_SCENARIOS
@@ -119,7 +93,7 @@ class CouchValidateSourceGenTests(LocalDatabaseValidateSourceGenTests):
super(CouchValidateSourceGenTests, self).tearDown()
-class CouchWithConflictsTests(LocalDatabaseWithConflictsTests):
+class CouchWithConflictsTests(test_backends.LocalDatabaseWithConflictsTests):
scenarios = COUCH_SCENARIOS
@@ -147,14 +121,14 @@ class CouchWithConflictsTests(LocalDatabaseWithConflictsTests):
#-----------------------------------------------------------------------------
target_scenarios = [
- ('local', {'create_db_and_target': _make_local_db_and_target}), ]
+ ('local', {'create_db_and_target': test_sync._make_local_db_and_target}), ]
simple_doc = tests.simple_doc
nested_doc = tests.nested_doc
-class CouchDatabaseSyncTargetTests(DatabaseSyncTargetTests):
+class CouchDatabaseSyncTargetTests(test_sync.DatabaseSyncTargetTests):
scenarios = (tests.multiply_scenarios(COUCH_SCENARIOS, target_scenarios))
@@ -188,11 +162,11 @@ class CouchDatabaseSyncTargetTests(DatabaseSyncTargetTests):
sync_scenarios = []
for name, scenario in COUCH_SCENARIOS:
scenario = dict(scenario)
- scenario['do_sync'] = sync_via_synchronizer
+ scenario['do_sync'] = test_sync.sync_via_synchronizer
sync_scenarios.append((name, scenario))
scenario = dict(scenario)
-class CouchDatabaseSyncTests(DatabaseSyncTests):
+class CouchDatabaseSyncTests(test_sync.DatabaseSyncTests):
scenarios = sync_scenarios
diff --git a/tests/test_encrypted.py b/tests/test_encrypted.py
index 4ee03a3c..8cb6dc51 100644
--- a/tests/test_encrypted.py
+++ b/tests/test_encrypted.py
@@ -1,8 +1,3 @@
-try:
- import simplejson as json
-except ImportError:
- import json # noqa
-
import unittest2 as unittest
import os
diff --git a/tests/test_leap_backend.py b/tests/test_leap_backend.py
index 0fa4033a..f19eb360 100644
--- a/tests/test_leap_backend.py
+++ b/tests/test_leap_backend.py
@@ -4,12 +4,8 @@ For these tests to run, a leap server has to be running on (default) port
5984.
"""
-from shutil import rmtree
import os
-import copy
import unittest2 as unittest
-import testtools
-import testscenarios
import u1db
from leap.soledad import Soledad
from leap.soledad.backends import leap_backend
@@ -18,41 +14,17 @@ from leap.soledad.tests.u1db_tests.test_remote_sync_target import (
make_http_app,
make_oauth_http_app,
)
-from leap.soledad.tests.u1db_tests.test_backends import AllDatabaseTests
-from leap.soledad.tests.u1db_tests.test_http_database import (
- TestHTTPDatabaseSimpleOperations,
- TestHTTPDatabaseCtrWithCreds,
- TestHTTPDatabaseIntegration,
-)
-from leap.soledad.tests.u1db_tests.test_http_client import (
- TestHTTPClientBase,
-)
-from leap.soledad.tests.u1db_tests.test_document import (
- TestDocument,
- TestPyDocument,
-)
-from leap.soledad.tests.u1db_tests.test_remote_sync_target import (
- TestHTTPSyncTargetBasics,
- TestParsingSyncStream,
-)
-from leap.soledad.tests.u1db_tests.test_sync import (
- _make_local_db_and_target,
- DatabaseSyncTargetTests,
-)
-from leap.soledad.tests.u1db_tests.test_https import (
- TestHttpSyncTargetHttpsSupport,
- https_server_def,
-)
+from leap.soledad.tests.u1db_tests import test_backends
+from leap.soledad.tests.u1db_tests import test_http_database
+from leap.soledad.tests.u1db_tests import test_http_client
+from leap.soledad.tests.u1db_tests import test_document
+from leap.soledad.tests.u1db_tests import test_remote_sync_target
+from leap.soledad.tests.u1db_tests import test_https
from leap.soledad.tests.test_encrypted import (
PUBLIC_KEY,
PRIVATE_KEY,
- KEY_FINGERPRINT,
)
-try:
- import simplejson as json
-except ImportError:
- import json # noqa
#-----------------------------------------------------------------------------
# The EncryptedSyncTest is used with multiple inheritance to guarantee that we
@@ -152,7 +124,7 @@ LEAP_SCENARIOS = [
]
-class LeapTests(AllDatabaseTests, SoledadTest):
+class LeapTests(test_backends.AllDatabaseTests, SoledadTest):
scenarios = LEAP_SCENARIOS
@@ -161,10 +133,10 @@ class LeapTests(AllDatabaseTests, SoledadTest):
# The following tests come from `u1db.tests.test_http_database`.
#-----------------------------------------------------------------------------
-class TestLeapDatabaseSimpleOperations(TestHTTPDatabaseSimpleOperations):
+class TestLeapDatabaseSimpleOperations(test_http_database.TestHTTPDatabaseSimpleOperations):
def setUp(self):
- super(TestHTTPDatabaseSimpleOperations, self).setUp()
+ super(test_http_database.TestHTTPDatabaseSimpleOperations, self).setUp()
self.db = leap_backend.LeapDatabase('dbase')
self.db._conn = object() # crash if used
self.got = None
@@ -193,11 +165,11 @@ class TestLeapDatabaseSimpleOperations(TestHTTPDatabaseSimpleOperations):
self.assertEqual(st._url, self.db._url)
-class TestLeapDatabaseCtrWithCreds(TestHTTPDatabaseCtrWithCreds):
+class TestLeapDatabaseCtrWithCreds(test_http_database.TestHTTPDatabaseCtrWithCreds):
pass
-class TestLeapDatabaseIntegration(TestHTTPDatabaseIntegration):
+class TestLeapDatabaseIntegration(test_http_database.TestHTTPDatabaseIntegration):
def test_non_existing_db(self):
db = leap_backend.LeapDatabase(self.getURL('not-there'))
@@ -252,7 +224,7 @@ class TestLeapDatabaseIntegration(TestHTTPDatabaseIntegration):
# The following tests come from `u1db.tests.test_http_client`.
#-----------------------------------------------------------------------------
-class TestLeapClientBase(TestHTTPClientBase):
+class TestLeapClientBase(test_http_client.TestHTTPClientBase):
pass
@@ -260,13 +232,13 @@ class TestLeapClientBase(TestHTTPClientBase):
# The following tests come from `u1db.tests.test_document`.
#-----------------------------------------------------------------------------
-class TestLeapDocument(TestDocument, SoledadTest):
+class TestLeapDocument(test_document.TestDocument, SoledadTest):
scenarios = ([(
'leap', {'make_document_for_test': make_leap_document_for_test})])
-class TestLeapPyDocument(TestPyDocument, SoledadTest):
+class TestLeapPyDocument(test_document.TestPyDocument, SoledadTest):
scenarios = ([(
'leap', {'make_document_for_test': make_leap_document_for_test})])
@@ -276,7 +248,7 @@ class TestLeapPyDocument(TestPyDocument, SoledadTest):
# The following tests come from `u1db.tests.test_remote_sync_target`.
#-----------------------------------------------------------------------------
-class TestLeapSyncTargetBasics(TestHTTPSyncTargetBasics):
+class TestLeapSyncTargetBasics(test_remote_sync_target.TestHTTPSyncTargetBasics):
def test_parse_url(self):
remote_target = leap_backend.LeapSyncTarget('http://127.0.0.1:12345/')
@@ -285,7 +257,7 @@ class TestLeapSyncTargetBasics(TestHTTPSyncTargetBasics):
self.assertEqual(12345, remote_target._url.port)
self.assertEqual('/', remote_target._url.path)
-class TestLeapParsingSyncStream(TestParsingSyncStream):
+class TestLeapParsingSyncStream(test_remote_sync_target.TestParsingSyncStream):
def test_wrong_start(self):
tgt = leap_backend.LeapSyncTarget("http://foo/foo")
@@ -386,10 +358,10 @@ def oauth_https_sync_target(test, host, path):
tests.token1.key, tests.token1.secret)
return st
-class TestLeapSyncTargetHttpsSupport(TestHttpSyncTargetHttpsSupport, SoledadTest):
+class TestLeapSyncTargetHttpsSupport(test_https.TestHttpSyncTargetHttpsSupport, SoledadTest):
scenarios = [
- ('oauth_https', {'server_def': https_server_def,
+ ('oauth_https', {'server_def': test_https.https_server_def,
'make_app_with_state': make_oauth_http_app,
'make_document_for_test': make_leap_document_for_test,
'sync_target': oauth_https_sync_target
diff --git a/tests/test_logs.py b/tests/test_logs.py
index 293425ad..0be0d1f9 100644
--- a/tests/test_logs.py
+++ b/tests/test_logs.py
@@ -1,4 +1,3 @@
-import ipdb
import unittest2 as unittest
from leap.soledad.backends.objectstore import TransactionLog, SyncLog, ConflictLog
diff --git a/tests/test_sqlcipher.py b/tests/test_sqlcipher.py
index 4457db53..cfccf605 100644
--- a/tests/test_sqlcipher.py
+++ b/tests/test_sqlcipher.py
@@ -23,22 +23,9 @@ from leap.soledad.backends.sqlcipher import open as u1db_open
# u1db tests stuff.
from leap.soledad.tests import u1db_tests as tests
-from leap.soledad.tests.u1db_tests.test_sqlite_backend import (
- TestSQLiteDatabase,
- TestSQLitePartialExpandDatabase,
-)
-from leap.soledad.tests.u1db_tests.test_backends import (
- TestAlternativeDocument,
- AllDatabaseTests,
- LocalDatabaseTests,
- LocalDatabaseValidateGenNTransIdTests,
- LocalDatabaseValidateSourceGenTests,
- LocalDatabaseWithConflictsTests,
- DatabaseIndexTests,
-)
-from leap.soledad.tests.u1db_tests.test_open import (
- TestU1DBOpen,
-)
+from leap.soledad.tests.u1db_tests import test_sqlite_backend
+from leap.soledad.tests.u1db_tests import test_backends
+from leap.soledad.tests.u1db_tests import test_open
PASSWORD = '123456'
@@ -94,27 +81,27 @@ SQLCIPHER_SCENARIOS = [
]
-class SQLCipherTests(AllDatabaseTests):
+class SQLCipherTests(test_backends.AllDatabaseTests):
scenarios = SQLCIPHER_SCENARIOS
-class SQLCipherDatabaseTests(LocalDatabaseTests):
+class SQLCipherDatabaseTests(test_backends.LocalDatabaseTests):
scenarios = SQLCIPHER_SCENARIOS
-class SQLCipherValidateGenNTransIdTests(LocalDatabaseValidateGenNTransIdTests):
+class SQLCipherValidateGenNTransIdTests(test_backends.LocalDatabaseValidateGenNTransIdTests):
scenarios = SQLCIPHER_SCENARIOS
-class SQLCipherValidateSourceGenTests(LocalDatabaseValidateSourceGenTests):
+class SQLCipherValidateSourceGenTests(test_backends.LocalDatabaseValidateSourceGenTests):
scenarios = SQLCIPHER_SCENARIOS
-class SQLCipherWithConflictsTests(LocalDatabaseWithConflictsTests):
+class SQLCipherWithConflictsTests(test_backends.LocalDatabaseWithConflictsTests):
scenarios = SQLCIPHER_SCENARIOS
-class SQLCipherIndexTests(DatabaseIndexTests):
+class SQLCipherIndexTests(test_backends.DatabaseIndexTests):
scenarios = SQLCIPHER_SCENARIOS
@@ -125,7 +112,7 @@ load_tests = tests.load_with_scenarios
# The following tests come from `u1db.tests.test_sqlite_backend`.
#-----------------------------------------------------------------------------
-class TestSQLCipherDatabase(TestSQLiteDatabase):
+class TestSQLCipherDatabase(test_sqlite_backend.TestSQLiteDatabase):
def test_atomic_initialize(self):
tmpdir = self.createTempDir()
@@ -170,14 +157,14 @@ class TestSQLCipherDatabase(TestSQLiteDatabase):
self.assertTrue(db2._is_initialized(db1._get_sqlite_handle().cursor()))
-class TestSQLCipherPartialExpandDatabase(TestSQLitePartialExpandDatabase):
+class TestSQLCipherPartialExpandDatabase(test_sqlite_backend.TestSQLitePartialExpandDatabase):
# The following tests had to be cloned from u1db because they all
# instantiate the backend directly, so we need to change that in order to
# our backend be instantiated in place.
def setUp(self):
- super(TestSQLitePartialExpandDatabase, self).setUp()
+ super(test_sqlite_backend.TestSQLitePartialExpandDatabase, self).setUp()
self.db = SQLCipherDatabase(':memory:', PASSWORD)
self.db._set_replica_uid('test')
@@ -229,8 +216,8 @@ class TestSQLCipherPartialExpandDatabase(TestSQLitePartialExpandDatabase):
path = temp_dir + '/test.sqlite'
SQLCipherDatabase(path, PASSWORD)
db2 = SQLCipherDatabase._open_database(
- path, PASSWORD, document_factory=TestAlternativeDocument)
- self.assertEqual(TestAlternativeDocument, db2._factory)
+ path, PASSWORD, document_factory=test_backends.TestAlternativeDocument)
+ self.assertEqual(test_backends.TestAlternativeDocument, db2._factory)
def test_open_database_existing(self):
temp_dir = self.createTempDir(prefix='u1db-test-')
@@ -244,8 +231,8 @@ class TestSQLCipherPartialExpandDatabase(TestSQLitePartialExpandDatabase):
path = temp_dir + '/existing.sqlite'
SQLCipherDatabase(path, PASSWORD)
db2 = SQLCipherDatabase.open_database(
- path, PASSWORD, create=False, document_factory=TestAlternativeDocument)
- self.assertEqual(TestAlternativeDocument, db2._factory)
+ path, PASSWORD, create=False, document_factory=test_backends.TestAlternativeDocument)
+ self.assertEqual(test_backends.TestAlternativeDocument, db2._factory)
def test_create_database_initializes_schema(self):
# This test had to be cloned because our implementation of SQLCipher
@@ -264,7 +251,7 @@ class TestSQLCipherPartialExpandDatabase(TestSQLitePartialExpandDatabase):
# The following tests come from `u1db.tests.test_open`.
#-----------------------------------------------------------------------------
-class SQLCipherOpen(TestU1DBOpen):
+class SQLCipherOpen(test_open.TestU1DBOpen):
def test_open_no_create(self):
self.assertRaises(errors.DatabaseDoesNotExist,
@@ -281,9 +268,9 @@ class SQLCipherOpen(TestU1DBOpen):
def test_open_with_factory(self):
db = u1db_open(self.db_path, password=PASSWORD, create=True,
- document_factory=TestAlternativeDocument)
+ document_factory=test_backends.TestAlternativeDocument)
self.addCleanup(db.close)
- self.assertEqual(TestAlternativeDocument, db._factory)
+ self.assertEqual(test_backends.TestAlternativeDocument, db._factory)
def test_open_existing(self):
db = SQLCipherDatabase(self.db_path, PASSWORD)