diff options
-rw-r--r-- | testing/README | 21 | ||||
-rw-r--r-- | testing/tests/client/test_deprecated_crypto.py | 2 | ||||
-rw-r--r-- | testing/tests/conftest.py | 8 | ||||
-rw-r--r-- | testing/tests/server/test_server.py | 1 | ||||
-rw-r--r-- | testing/tests/server/test_shared_db.py | 1 | ||||
-rw-r--r-- | testing/tests/server/test_url_mapper.py | 2 | ||||
-rw-r--r-- | testing/tests/sync/test_sync.py | 2 | ||||
-rw-r--r-- | testing/tests/sync/test_sync_mutex.py | 2 | ||||
-rw-r--r-- | testing/tests/sync/test_sync_target.py | 5 |
9 files changed, 44 insertions, 0 deletions
diff --git a/testing/README b/testing/README new file mode 100644 index 00000000..94be7250 --- /dev/null +++ b/testing/README @@ -0,0 +1,21 @@ +Soledad Tests +============= + +This folder contains all tests for Soledad client and server. + +Dependency on CouchDB +--------------------- + +Currently, some tests depend on availability of a CouchDB server. You can pass +a custom couchdb url by using the --couch-url option when running tox (or +pytest), like this: + + tox -- --couch-url http://couch_host:5984 + +Tests that depend on couchdb are marked as such with the 'needs_couch' pytest +marker. You can skip them by avoiding tests with that marker: + + tox -- -m 'not needs_couch' + +In the future we want to isolate all tests that need couch as integration +tests, and use mocks everywhere else. diff --git a/testing/tests/client/test_deprecated_crypto.py b/testing/tests/client/test_deprecated_crypto.py index cdebcb3e..939a2003 100644 --- a/testing/tests/client/test_deprecated_crypto.py +++ b/testing/tests/client/test_deprecated_crypto.py @@ -1,4 +1,5 @@ import json +import pytest from pytest import inlineCallbacks from six.moves.urllib.parse import urljoin @@ -40,6 +41,7 @@ class DeprecatedCryptoTest(SoledadWithCouchServerMixin, TestCaseWithServer): def make_app_with_state(state): return make_token_soledad_app(state) + @pytest.mark.needs_couch @inlineCallbacks def test_touch_updates_remote_representation(self): self.startTwistedServer() diff --git a/testing/tests/conftest.py b/testing/tests/conftest.py index 2459307a..4d88072e 100644 --- a/testing/tests/conftest.py +++ b/testing/tests/conftest.py @@ -16,6 +16,14 @@ from leap.soledad.common.couch import CouchDatabase from leap.soledad.client import Soledad +# mark tests that depend on couchdb +def pytest_collection_modifyitems(items): + marker = getattr(pytest.mark, 'needs_couch') + for item in items: + if 'soledad/testing/tests/couch/' in item.module.__file__: + item.add_marker(marker) + + # # default options for all tests # diff --git a/testing/tests/server/test_server.py b/testing/tests/server/test_server.py index bc80905e..25f0cc2d 100644 --- a/testing/tests/server/test_server.py +++ b/testing/tests/server/test_server.py @@ -40,6 +40,7 @@ from leap.soledad.client import _crypto from leap.soledad.client import Soledad +@pytest.mark.needs_couch @pytest.mark.usefixtures("method_tmpdir") class EncryptedSyncTestCase( CouchDBTestCase, TestCaseWithServer): diff --git a/testing/tests/server/test_shared_db.py b/testing/tests/server/test_shared_db.py index 4f3b1787..96af6dff 100644 --- a/testing/tests/server/test_shared_db.py +++ b/testing/tests/server/test_shared_db.py @@ -28,6 +28,7 @@ from leap.soledad.common.document import SoledadDocument from leap.soledad.common.l2db.errors import RevisionConflict +@pytest.mark.needs_couch class SharedDbTests(unittest.TestCase): """ """ diff --git a/testing/tests/server/test_url_mapper.py b/testing/tests/server/test_url_mapper.py index fa99cae7..a04e7593 100644 --- a/testing/tests/server/test_url_mapper.py +++ b/testing/tests/server/test_url_mapper.py @@ -17,6 +17,7 @@ """ Tests for server-related functionality. """ +import pytest from twisted.trial import unittest from uuid import uuid4 @@ -49,6 +50,7 @@ class URLMapperTestCase(unittest.TestCase): self._urlmap = URLMapper() self._dbname = 'user-%s' % self._uuid + @pytest.mark.needs_couch def test_root_authorized(self): match = self._urlmap.match('/', 'GET') self.assertIsNotNone(match) diff --git a/testing/tests/sync/test_sync.py b/testing/tests/sync/test_sync.py index bce20894..fb9a0245 100644 --- a/testing/tests/sync/test_sync.py +++ b/testing/tests/sync/test_sync.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import json +import pytest import threading import time @@ -141,6 +142,7 @@ class InterruptableSyncTestCase( return d +@pytest.mark.needs_couch class TestSoledadDbSync( TestWithScenarios, SoledadWithCouchServerMixin, diff --git a/testing/tests/sync/test_sync_mutex.py b/testing/tests/sync/test_sync_mutex.py index a9335973..fdd2aacd 100644 --- a/testing/tests/sync/test_sync_mutex.py +++ b/testing/tests/sync/test_sync_mutex.py @@ -22,6 +22,7 @@ be two concurrent synchronization processes at the same time. """ +import pytest import time import uuid @@ -72,6 +73,7 @@ SoledadSynchronizer.sync = _timed_sync # -- end of monkey-patching +@pytest.mark.needs_couch class TestSyncMutex( BaseSoledadTest, CouchDBTestCase, TestCaseWithServer): diff --git a/testing/tests/sync/test_sync_target.py b/testing/tests/sync/test_sync_target.py index bfa322dc..712f0d3f 100644 --- a/testing/tests/sync/test_sync_target.py +++ b/testing/tests/sync/test_sync_target.py @@ -20,6 +20,7 @@ Test Leap backend bits: sync target import os import time import json +import pytest import random import string import shutil @@ -148,6 +149,7 @@ def make_local_db_and_token_soledad_target( return db, st +@pytest.mark.needs_couch class TestSoledadSyncTarget( TestWithScenarios, SoledadWithCouchServerMixin, @@ -401,6 +403,7 @@ target_scenarios = [ ] +@pytest.mark.needs_couch class SoledadDatabaseSyncTargetTests( TestWithScenarios, SoledadWithCouchServerMixin, @@ -795,6 +798,7 @@ class SyncTimeoutError(Exception): pass +@pytest.mark.needs_couch class TestSoledadDbSync( TestWithScenarios, SoledadWithCouchServerMixin, @@ -952,6 +956,7 @@ class TestSoledadDbSync( return d +@pytest.mark.needs_couch class SQLCipherSyncTargetTests(SoledadDatabaseSyncTargetTests): # TODO: implement _set_trace_hook(_shallow) in SoledadHTTPSyncTarget so |