diff options
author | Kali Kaneko <kali@leap.se> | 2015-08-04 17:56:35 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-08-04 17:56:35 -0400 |
commit | 0b1e55d3142d7012cd7fef39b6ed77be69d5ee11 (patch) | |
tree | 83a96143cfbdc1eb549c2b5ee6fca40e9685230a /common/src/leap/soledad | |
parent | c1b99f965f248c20e19eac44b3da239a9e6828ac (diff) |
[style] pep8 cleanup
Diffstat (limited to 'common/src/leap/soledad')
23 files changed, 99 insertions, 28 deletions
diff --git a/common/src/leap/soledad/common/_version.py b/common/src/leap/soledad/common/_version.py index 538b829d..a58af503 100644 --- a/common/src/leap/soledad/common/_version.py +++ b/common/src/leap/soledad/common/_version.py @@ -129,11 +129,11 @@ def versions_from_vcs(tag_prefix, versionfile_source, verbose=False): root = os.path.dirname( os.path.join('..', here)) - ###################################################### + # # XXX patch for our specific configuration with # the three projects leap.soledad.{common, client, server} # inside the same repo. - ###################################################### + # root = os.path.dirname(os.path.join('..', root)) if not os.path.exists(os.path.join(root, ".git")): diff --git a/common/src/leap/soledad/common/couch.py b/common/src/leap/soledad/common/couch.py index ae9e7d2a..1747d067 100644 --- a/common/src/leap/soledad/common/couch.py +++ b/common/src/leap/soledad/common/couch.py @@ -71,12 +71,14 @@ COUCH_TIMEOUT = 120 # timeout for transfers between Soledad server and Couch class InvalidURLError(Exception): + """ Exception raised when Soledad encounters a malformed URL. """ class CouchDocument(SoledadDocument): + """ This is the document used for maintaining the Couch backend. @@ -251,6 +253,7 @@ def raise_server_error(exc, ddoc_path): class MultipartWriter(object): + """ A multipart writer adapted from python-couchdb's one so we can PUT documents using couch's multipart PUT. @@ -356,6 +359,7 @@ def couch_server(url): class CouchDatabase(CommonBackend): + """ A U1DB implementation that uses CouchDB as its persistence layer. """ @@ -367,6 +371,7 @@ class CouchDatabase(CommonBackend): sync_info_lock = defaultdict(threading.Lock) class _GetDocThread(threading.Thread): + """ A thread that gets a document from a database. @@ -1506,6 +1511,7 @@ class CouchDatabase(CommonBackend): class CouchSyncTarget(CommonSyncTarget): + """ Functionality for using a CouchDatabase as a synchronization target. """ @@ -1528,6 +1534,7 @@ class CouchSyncTarget(CommonSyncTarget): class CouchServerState(ServerState): + """ Inteface of the WSGI server with the CouchDB backend. """ diff --git a/common/src/leap/soledad/common/crypto.py b/common/src/leap/soledad/common/crypto.py index 77a5a93b..c13c4aa7 100644 --- a/common/src/leap/soledad/common/crypto.py +++ b/common/src/leap/soledad/common/crypto.py @@ -26,6 +26,7 @@ Soledad common crypto bits. # class EncryptionSchemes(object): + """ Representation of encryption schemes used to encrypt documents. """ @@ -36,6 +37,7 @@ class EncryptionSchemes(object): class UnknownEncryptionSchemeError(Exception): + """ Raised when trying to decrypt from unknown encryption schemes. """ @@ -43,6 +45,7 @@ class UnknownEncryptionSchemeError(Exception): class EncryptionMethods(object): + """ Representation of encryption methods that can be used. """ @@ -51,6 +54,7 @@ class EncryptionMethods(object): class UnknownEncryptionMethodError(Exception): + """ Raised when trying to encrypt/decrypt with unknown method. """ @@ -58,6 +62,7 @@ class UnknownEncryptionMethodError(Exception): class MacMethods(object): + """ Representation of MAC methods used to authenticate document's contents. """ @@ -66,6 +71,7 @@ class MacMethods(object): class UnknownMacMethodError(Exception): + """ Raised when trying to authenticate document's content with unknown MAC mehtod. @@ -74,6 +80,7 @@ class UnknownMacMethodError(Exception): class WrongMacError(Exception): + """ Raised when failing to authenticate document's contents based on MAC. """ diff --git a/common/src/leap/soledad/common/errors.py b/common/src/leap/soledad/common/errors.py index ea4bf7f6..f285cc77 100644 --- a/common/src/leap/soledad/common/errors.py +++ b/common/src/leap/soledad/common/errors.py @@ -40,6 +40,7 @@ def register_exception(cls): class SoledadError(errors.U1DBError): + """ Base Soledad HTTP errors. """ @@ -52,6 +53,7 @@ class SoledadError(errors.U1DBError): @register_exception class InvalidAuthTokenError(errors.Unauthorized): + """ Exception raised when failing to get authorization for some action because the provided token either does not exist in the tokens database, has a @@ -69,6 +71,7 @@ class InvalidAuthTokenError(errors.Unauthorized): @register_exception class InvalidTokenError(SoledadError): + """ Exception raised when trying to unlock shared database with invalid token. """ @@ -79,6 +82,7 @@ class InvalidTokenError(SoledadError): @register_exception class NotLockedError(SoledadError): + """ Exception raised when trying to unlock shared database when it is not locked. @@ -90,6 +94,7 @@ class NotLockedError(SoledadError): @register_exception class AlreadyLockedError(SoledadError): + """ Exception raised when trying to lock shared database but it is already locked. @@ -101,6 +106,7 @@ class AlreadyLockedError(SoledadError): @register_exception class LockTimedOutError(SoledadError): + """ Exception raised when timing out while trying to lock the shared database. """ @@ -111,6 +117,7 @@ class LockTimedOutError(SoledadError): @register_exception class CouldNotObtainLockError(SoledadError): + """ Exception raised when timing out while trying to lock the shared database. """ @@ -125,6 +132,7 @@ class CouldNotObtainLockError(SoledadError): @register_exception class MissingDesignDocError(SoledadError): + """ Raised when trying to access a missing couch design document. """ @@ -135,6 +143,7 @@ class MissingDesignDocError(SoledadError): @register_exception class MissingDesignDocNamedViewError(SoledadError): + """ Raised when trying to access a missing named view on a couch design document. @@ -146,6 +155,7 @@ class MissingDesignDocNamedViewError(SoledadError): @register_exception class MissingDesignDocListFunctionError(SoledadError): + """ Raised when trying to access a missing list function on a couch design document. @@ -157,6 +167,7 @@ class MissingDesignDocListFunctionError(SoledadError): @register_exception class MissingDesignDocDeletedError(SoledadError): + """ Raised when trying to access a deleted couch design document. """ @@ -167,6 +178,7 @@ class MissingDesignDocDeletedError(SoledadError): @register_exception class DesignDocUnknownError(SoledadError): + """ Raised when trying to access a couch design document and getting an unknown error. diff --git a/common/src/leap/soledad/common/tests/server_state.py b/common/src/leap/soledad/common/tests/server_state.py index 2bc15377..2fe9472f 100644 --- a/common/src/leap/soledad/common/tests/server_state.py +++ b/common/src/leap/soledad/common/tests/server_state.py @@ -33,6 +33,7 @@ from leap.soledad.common.tests.util import ( class ServerStateForTests(ServerState): + """Passed to a Request when it is instantiated. This is used to track server-side state, such as working-directory, open diff --git a/common/src/leap/soledad/common/tests/test_async.py b/common/src/leap/soledad/common/tests/test_async.py index 5f273e08..302ecc37 100644 --- a/common/src/leap/soledad/common/tests/test_async.py +++ b/common/src/leap/soledad/common/tests/test_async.py @@ -27,6 +27,7 @@ from leap.soledad.client.sqlcipher import SQLCipherOptions class ASyncSQLCipherRetryTestCase(BaseSoledadTest): + """ Test asynchronous SQLCipher operation. """ diff --git a/common/src/leap/soledad/common/tests/test_crypto.py b/common/src/leap/soledad/common/tests/test_crypto.py index 55ecbdd7..ca10a1e1 100644 --- a/common/src/leap/soledad/common/tests/test_crypto.py +++ b/common/src/leap/soledad/common/tests/test_crypto.py @@ -34,6 +34,7 @@ from leap.soledad.common.crypto import MAC_METHOD_KEY class EncryptedSyncTestCase(BaseSoledadTest): + """ Tests that guarantee that data will always be encrypted when syncing. """ @@ -71,7 +72,8 @@ class RecoveryDocumentTestCase(BaseSoledadTest): self.assertEqual(secret_id, self._soledad.secrets._secret_id) self.assertEqual(secret, self._soledad.secrets._secrets[secret_id]) # assert recovery document structure - encrypted_secret = rd[self._soledad.secrets.STORAGE_SECRETS_KEY][secret_id] + encrypted_secret = rd[ + self._soledad.secrets.STORAGE_SECRETS_KEY][secret_id] self.assertTrue(self._soledad.secrets.CIPHER_KEY in encrypted_secret) self.assertTrue( encrypted_secret[self._soledad.secrets.CIPHER_KEY] == 'aes256') diff --git a/common/src/leap/soledad/common/tests/test_encdecpool.py b/common/src/leap/soledad/common/tests/test_encdecpool.py index 9334f88c..a741d993 100644 --- a/common/src/leap/soledad/common/tests/test_encdecpool.py +++ b/common/src/leap/soledad/common/tests/test_encdecpool.py @@ -71,10 +71,11 @@ class TestSyncEncrypterPool(TestCase, BaseSoledadTest): while encrypted is None and attempts < 10: encrypted = yield self._pool.get_encrypted_doc(DOC_ID, DOC_REV) attempts += 1 - + self.assertIsNotNone(encrypted) self.assertTrue(attempts < 10) + class TestSyncDecrypterPool(TestCase, BaseSoledadTest): def _insert_doc_cb(self, doc, gen, trans_id): @@ -106,7 +107,7 @@ class TestSyncDecrypterPool(TestCase, BaseSoledadTest): """ self._pool.start(1) self._pool.insert_received_doc( - DOC_ID, DOC_REV, "{}", 1, "trans_id", 1) + DOC_ID, DOC_REV, "{}", 1, "trans_id", 1) def _assert_doc_was_inserted(_): self.assertEqual( @@ -168,7 +169,7 @@ class TestSyncDecrypterPool(TestCase, BaseSoledadTest): # insert the encrypted document in the pool self._pool.start(1) self._pool.insert_encrypted_received_doc( - DOC_ID, DOC_REV, encrypted_content, 1, "trans_id", 1) + DOC_ID, DOC_REV, encrypted_content, 1, "trans_id", 1) def _assert_doc_was_decrypted_and_inserted(_): self.assertEqual(self._inserted_docs, [(doc, 1, u"trans_id")]) diff --git a/common/src/leap/soledad/common/tests/test_http.py b/common/src/leap/soledad/common/tests/test_http.py index bedd1868..bc486fe3 100644 --- a/common/src/leap/soledad/common/tests/test_http.py +++ b/common/src/leap/soledad/common/tests/test_http.py @@ -28,6 +28,7 @@ from leap.soledad.common.tests.u1db_tests import test_http_database # ----------------------------------------------------------------------------- class _HTTPDatabase(http_database.HTTPDatabase, auth.TokenBasedAuth): + """ Wraps our token auth implementation. """ diff --git a/common/src/leap/soledad/common/tests/test_http_client.py b/common/src/leap/soledad/common/tests/test_http_client.py index fcf5f75e..700ae3b6 100644 --- a/common/src/leap/soledad/common/tests/test_http_client.py +++ b/common/src/leap/soledad/common/tests/test_http_client.py @@ -35,6 +35,7 @@ from leap.soledad.server.auth import SoledadTokenAuthMiddleware class TestSoledadClientBase( TestWithScenarios, test_http_client.TestHTTPClientBase): + """ This class should be used to test Token auth. """ diff --git a/common/src/leap/soledad/common/tests/test_https.py b/common/src/leap/soledad/common/tests/test_https.py index 93619515..eeeb4982 100644 --- a/common/src/leap/soledad/common/tests/test_https.py +++ b/common/src/leap/soledad/common/tests/test_https.py @@ -83,7 +83,8 @@ class TestSoledadHTTPSyncTargetHttpsSupport( # run smoothly with standard u1db. test_https.TestHttpSyncTargetHttpsSupport.setUp(self) # so here monkey patch again to test our functionality. - http_client._VerifiedHTTPSConnection = client.api.VerifiedHTTPSConnection + api = client.api + http_client._VerifiedHTTPSConnection = api.VerifiedHTTPSConnection client.api.SOLEDAD_CERT = http_client.CA_CERTS def test_cannot_verify_cert(self): diff --git a/common/src/leap/soledad/common/tests/test_server.py b/common/src/leap/soledad/common/tests/test_server.py index 47cbf4d1..3ed23184 100644 --- a/common/src/leap/soledad/common/tests/test_server.py +++ b/common/src/leap/soledad/common/tests/test_server.py @@ -59,6 +59,7 @@ CouchServerState.ensure_database = _couch_ensure_database class ServerAuthorizationTestCase(BaseSoledadTest): + """ Tests related to Soledad server authorization. """ @@ -268,6 +269,7 @@ class ServerAuthorizationTestCase(BaseSoledadTest): class EncryptedSyncTestCase( CouchDBTestCase, TestCaseWithServer): + """ Tests for encrypted sync using Soledad server backed by a couch database. """ @@ -456,7 +458,7 @@ class EncryptedSyncTestCase( """ Test if Soledad can sync very large files. """ - length = 100 * (10**6) # 100 MB + length = 100 * (10 ** 6) # 100 MB return self._test_encrypted_sym_sync(doc_size=length, number_of_docs=1) def test_sync_many_small_files(self): @@ -468,6 +470,7 @@ class EncryptedSyncTestCase( class LockResourceTestCase( CouchDBTestCase, TestCaseWithServer): + """ Tests for use of PUT and DELETE on lock resource. """ diff --git a/common/src/leap/soledad/common/tests/test_soledad.py b/common/src/leap/soledad/common/tests/test_soledad.py index 1cd74dad..8c791672 100644 --- a/common/src/leap/soledad/common/tests/test_soledad.py +++ b/common/src/leap/soledad/common/tests/test_soledad.py @@ -165,6 +165,7 @@ class AuxMethodsTestCase(BaseSoledadTest): class SoledadSharedDBTestCase(BaseSoledadTest): + """ These tests ensure the functionalities of the shared recovery database. """ @@ -209,6 +210,7 @@ class SoledadSharedDBTestCase(BaseSoledadTest): class SoledadSignalingTestCase(BaseSoledadTest): + """ These tests ensure signals are correctly emmited by Soledad. """ diff --git a/common/src/leap/soledad/common/tests/test_soledad_app.py b/common/src/leap/soledad/common/tests/test_soledad_app.py index 07ad00a0..4598a7bb 100644 --- a/common/src/leap/soledad/common/tests/test_soledad_app.py +++ b/common/src/leap/soledad/common/tests/test_soledad_app.py @@ -49,11 +49,10 @@ class SoledadTests( TestWithScenarios, test_backends.AllDatabaseTests, BaseSoledadTest): scenarios = LEAP_SCENARIOS + [ - ('token_http', {'make_database_for_test': - make_token_http_database_for_test, - 'copy_database_for_test': - copy_token_http_database_for_test, - 'make_document_for_test': make_soledad_document_for_test, - 'make_app_with_state': make_token_soledad_app, - }) + ('token_http', { + 'make_database_for_test': make_token_http_database_for_test, + 'copy_database_for_test': copy_token_http_database_for_test, + 'make_document_for_test': make_soledad_document_for_test, + 'make_app_with_state': make_token_soledad_app, + }) ] diff --git a/common/src/leap/soledad/common/tests/test_sqlcipher.py b/common/src/leap/soledad/common/tests/test_sqlcipher.py index e1b92fb4..4d23f1be 100644 --- a/common/src/leap/soledad/common/tests/test_sqlcipher.py +++ b/common/src/leap/soledad/common/tests/test_sqlcipher.py @@ -97,7 +97,8 @@ class SQLCipherTests(TestWithScenarios, test_backends.AllDatabaseTests): scenarios = SQLCIPHER_SCENARIOS -class SQLCipherDatabaseTests(TestWithScenarios, test_backends.LocalDatabaseTests): +class SQLCipherDatabaseTests(TestWithScenarios, + test_backends.LocalDatabaseTests): scenarios = SQLCIPHER_SCENARIOS @@ -128,7 +129,8 @@ class SQLCipherIndexTests( # The following tests come from `u1db.tests.test_sqlite_backend`. # ----------------------------------------------------------------------------- -class TestSQLCipherDatabase(TestWithScenarios, test_sqlite_backend.TestSQLiteDatabase): +class TestSQLCipherDatabase(TestWithScenarios, + test_sqlite_backend.TestSQLiteDatabase): def test_atomic_initialize(self): # This test was modified to ensure that db2.close() is called within @@ -181,6 +183,7 @@ class TestSQLCipherDatabase(TestWithScenarios, test_sqlite_backend.TestSQLiteDat class TestAlternativeDocument(SoledadDocument): + """A (not very) alternative implementation of Document.""" @@ -372,6 +375,7 @@ class SQLCipherOpen(test_open.TestU1DBOpen): # ----------------------------------------------------------------------------- class SQLCipherEncryptionTest(BaseSoledadTest): + """ Tests to guarantee SQLCipher is indeed encrypting data when storing. """ diff --git a/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py b/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py index 869ecf9a..f9da9a99 100644 --- a/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py +++ b/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py @@ -50,7 +50,8 @@ from leap.soledad.common.tests.util import ( # ----------------------------------------------------------------------------- def sync_via_synchronizer_and_soledad(test, db_source, db_target, - trace_hook=None, trace_hook_shallow=None): + trace_hook=None, + trace_hook_shallow=None): if trace_hook: test.skipTest("full trace hook unsupported over http") path = test._http_at[db_target] @@ -72,6 +73,7 @@ class SQLCipherDatabaseSyncTests( TestWithScenarios, test_sync.DatabaseSyncTests, BaseSoledadTest): + """ Test for succesfull sync between SQLCipher and LeapBackend. diff --git a/common/src/leap/soledad/common/tests/test_sync.py b/common/src/leap/soledad/common/tests/test_sync.py index 9449f269..50fcc9f8 100644 --- a/common/src/leap/soledad/common/tests/test_sync.py +++ b/common/src/leap/soledad/common/tests/test_sync.py @@ -45,6 +45,7 @@ from leap.soledad.common.tests.test_couch import CouchDBTestCase class InterruptableSyncTestCase( BaseSoledadTest, CouchDBTestCase, TestCaseWithServer): + """ Tests for encrypted sync using Soledad server backed by a couch database. """ @@ -77,6 +78,7 @@ class InterruptableSyncTestCase( """ class _SyncInterruptor(threading.Thread): + """ A thread meant to interrupt the sync process. """ @@ -97,7 +99,8 @@ class InterruptableSyncTestCase( self.startServer() # instantiate soledad and create a document - sol = self._soledad_instance(user='user-uuid', server_url=self.getURL()) + sol = self._soledad_instance( + user='user-uuid', server_url=self.getURL()) # ensure remote db exists before syncing db = couch.CouchDatabase.open_database( @@ -122,14 +125,18 @@ class InterruptableSyncTestCase( # sync with server d.addCallback(_create_docs) d.addCallback(lambda _: sol.get_all_docs()) - d.addCallback(lambda results: self.assertEqual(number_of_docs, len(results[1]))) + d.addCallback( + lambda results: self.assertEqual(number_of_docs, len(results[1]))) d.addCallback(lambda _: sol.sync()) d.addCallback(lambda _: t.join()) d.addCallback(lambda _: db.get_all_docs()) - d.addCallback(lambda results: self.assertNotEqual(number_of_docs, len(results[1]))) + d.addCallback( + lambda results: self.assertNotEqual( + number_of_docs, len(results[1]))) d.addCallback(lambda _: sol.sync()) d.addCallback(lambda _: db.get_all_docs()) - d.addCallback(lambda results: self.assertEqual(number_of_docs, len(results[1]))) + d.addCallback( + lambda results: self.assertEqual(number_of_docs, len(results[1]))) def _tear_down(results): db.delete_database() @@ -148,6 +155,7 @@ class TestSoledadDbSync( TestWithScenarios, SoledadWithCouchServerMixin, test_sync.TestDbSync): + """ Test db.sync remote sync shortcut """ diff --git a/common/src/leap/soledad/common/tests/test_sync_deferred.py b/common/src/leap/soledad/common/tests/test_sync_deferred.py index 33c54641..dcbd16f6 100644 --- a/common/src/leap/soledad/common/tests/test_sync_deferred.py +++ b/common/src/leap/soledad/common/tests/test_sync_deferred.py @@ -49,6 +49,7 @@ DBPASS = "pass" class BaseSoledadDeferredEncTest(SoledadWithCouchServerMixin): + """ Another base class for testing the deferred encryption/decryption during the syncs, using the intermediate database. @@ -102,6 +103,7 @@ class BaseSoledadDeferredEncTest(SoledadWithCouchServerMixin): class SyncTimeoutError(Exception): + """ Dummy exception to notify timeout during sync. """ @@ -112,6 +114,7 @@ class TestSoledadDbSyncDeferredEncDecr( TestWithScenarios, test_sync.TestDbSync, BaseSoledadDeferredEncTest): + """ Test db.sync remote sync shortcut. Case with deferred encryption and decryption: using the intermediate @@ -205,8 +208,8 @@ class TestSoledadDbSyncDeferredEncDecr( def _assert_successful_sync(results): import time # need to give time to the encryption to proceed - # TODO should implement a defer list to subscribe to the all-decrypted - # event + # TODO should implement a defer list to subscribe to the + # all-decrypted event time.sleep(2) local_gen_before_sync = results self.wait_for_sync() diff --git a/common/src/leap/soledad/common/tests/test_sync_target.py b/common/src/leap/soledad/common/tests/test_sync_target.py index 65c7a2f2..75ab70cf 100644 --- a/common/src/leap/soledad/common/tests/test_sync_target.py +++ b/common/src/leap/soledad/common/tests/test_sync_target.py @@ -57,6 +57,7 @@ from leap.soledad.common.tests.u1db_tests import test_sync class TestSoledadSyncTargetBasics( test_remote_sync_target.TestHTTPSyncTargetBasics): + """ Some tests had to be copied to this class so we can instantiate our own target. @@ -73,6 +74,7 @@ class TestSoledadSyncTargetBasics( class TestSoledadParsingSyncStream( test_remote_sync_target.TestParsingSyncStream, BaseSoledadTest): + """ Some tests had to be copied to this class so we can instantiate our own target. @@ -444,6 +446,7 @@ DBPASS = "pass" class SyncTimeoutError(Exception): + """ Dummy exception to notify timeout during sync. """ @@ -454,6 +457,7 @@ class TestSoledadDbSync( TestWithScenarios, SoledadWithCouchServerMixin, test_sync.TestDbSync): + """Test db.sync remote sync shortcut""" scenarios = [ @@ -581,8 +585,8 @@ class TestSoledadDbSync( def _assert_successful_sync(results): import time # need to give time to the encryption to proceed - # TODO should implement a defer list to subscribe to the all-decrypted - # event + # TODO should implement a defer list to subscribe to the + # all-decrypted event time.sleep(2) local_gen_before_sync = results self.wait_for_sync() diff --git a/common/src/leap/soledad/common/tests/u1db_tests/__init__.py b/common/src/leap/soledad/common/tests/u1db_tests/__init__.py index 787494d3..9efe7ebf 100644 --- a/common/src/leap/soledad/common/tests/u1db_tests/__init__.py +++ b/common/src/leap/soledad/common/tests/u1db_tests/__init__.py @@ -238,6 +238,7 @@ class DatabaseBaseTests(TestCase): class ServerStateForTests(server_state.ServerState): + """Used in the test suite, so we don't have to touch disk, etc.""" def __init__(self): @@ -284,6 +285,7 @@ class ServerStateForTests(server_state.ServerState): class ResponderForTests(object): + """Responder for tests.""" _started = False sent_response = False @@ -309,6 +311,7 @@ class TestCaseWithServer(TestCase): # hook point # should return (ServerClass, "shutdown method name", "url_scheme") class _RequestHandler(simple_server.WSGIRequestHandler): + def log_request(*args): pass # suppress @@ -394,6 +397,7 @@ token3 = oauth.OAuthToken('kkkk3', 'ZYX') class TestingOAuthDataStore(oauth.OAuthDataStore): + """In memory predefined OAuthDataStore for testing.""" consumers = { diff --git a/common/src/leap/soledad/common/tests/u1db_tests/test_backends.py b/common/src/leap/soledad/common/tests/u1db_tests/test_backends.py index f26a4474..e777996e 100644 --- a/common/src/leap/soledad/common/tests/u1db_tests/test_backends.py +++ b/common/src/leap/soledad/common/tests/u1db_tests/test_backends.py @@ -78,6 +78,7 @@ def copy_oauth_http_database_for_test(test, db): class TestAlternativeDocument(DocumentBase): + """A (not very) alternative implementation of Document.""" diff --git a/common/src/leap/soledad/common/tests/u1db_tests/test_http_app.py b/common/src/leap/soledad/common/tests/u1db_tests/test_http_app.py index c545aa55..3ca50d93 100644 --- a/common/src/leap/soledad/common/tests/u1db_tests/test_http_app.py +++ b/common/src/leap/soledad/common/tests/u1db_tests/test_http_app.py @@ -1134,6 +1134,7 @@ class TestPluggableSyncExchange(tests.TestCase): def test_plugging(self): class MySyncExchange(object): + def __init__(self, db, source_replica_uid, last_known_generation): pass diff --git a/common/src/leap/soledad/common/tests/util.py b/common/src/leap/soledad/common/tests/util.py index cbd92b94..f7a2bd4e 100644 --- a/common/src/leap/soledad/common/tests/util.py +++ b/common/src/leap/soledad/common/tests/util.py @@ -186,6 +186,7 @@ def token_soledad_sync_target(test, path): class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): + """ Instantiates Soledad for usage in tests. """ @@ -314,6 +315,7 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): # from: https://github.com/smcq/paisley/blob/master/paisley/test/util.py # TODO: include license of above project. class CouchDBWrapper(object): + """ Wrapper for external CouchDB instance which is started and stopped for testing. @@ -331,7 +333,8 @@ class CouchDBWrapper(object): print traceback.format_exc() self.stop() tries += 1 - raise Exception("Check your couchdb: Tried to start 3 times and failed badly") + raise Exception( + "Check your couchdb: Tried to start 3 times and failed badly") def _try_start(self): """ @@ -358,7 +361,8 @@ class CouchDBWrapper(object): # create the dirs from the template mkdir_p(os.path.join(self.tempdir, 'lib')) mkdir_p(os.path.join(self.tempdir, 'log')) - args = ['/usr/bin/couchdb', '-n', '-a', defaultConfPath, '-a', confPath] + args = ['/usr/bin/couchdb', '-n', + '-a', defaultConfPath, '-a', confPath] null = open('/dev/null', 'w') self.process = subprocess.Popen( @@ -418,6 +422,7 @@ stderr: class CouchDBTestCase(unittest.TestCase, MockedSharedDBTest): + """ TestCase base class for tests against a real CouchDB server. """ @@ -438,6 +443,7 @@ class CouchDBTestCase(unittest.TestCase, MockedSharedDBTest): class CouchServerStateForTests(CouchServerState): + """ This is a slightly modified CouchDB server state that allows for creating a database. |