summaryrefslogtreecommitdiff
path: root/common/src/leap/soledad
AgeCommit message (Collapse)Author
2015-09-11[tests] db3 is expected to be an attributeVictor Shyba
self.db3 is closed on tearDown. This test was creating it as a local variable, making close possibly fail.
2015-09-11[tests] simplify make_app and getTarget codeVictor Shyba
It was hardcoded for 'test', but the database name is now random. What is useful for test code is the replica_uid, database name for the SyncTarget is now coming from database name.
2015-09-11[tests] isolate LockResource tests using a mockVictor Shyba
'shared' has to be used as a DB name just because of a constant, but it is used on only one point. This changes mock this point to have unique names for better tests isolation. 'tokens' was removed as unnecessary.
2015-09-11[tests] extract db creation with doc ensure methodVictor Shyba
This was a duplicate, but also was getting on the way to improve isolation. With this small refactor it should be cleaner and have unique names.
2015-09-11[tests] use addCleanup to ensure db deletionVictor Shyba
Test case has a addCleanup method, which provides a way to clean resources up and express this need as soon as you create. We are now using it to simplify some logic on database deletion during the test and to make sure that as soon as it gets created a cleanup is there to delete after.
2015-09-11[tests] isolate database names, use uuidVictor Shyba
We are using a single CouchDB install, which may cause tests to overlap since many of them uses the same database name, hurting isolation. This change tries to use uuid on most of it. Also changes for couch_url and couch_port introduced by removal of CouchDB process.
2015-09-11[tests] get rid of CouchDB python processVictor Shyba
This process per test gives a lot of headache, this is why we are removing it. With it we would need to try to start and stop properly on each test case. This fails badly when a test fail and, depending on how it fails, it freezes my pc. Also, it is very heavy for a CI to run a database process for each test case.
2015-08-28[style] pep8 fixesKali Kaneko
2015-08-27[tests] fix variable name from refactorVictor Shyba
From: [refactor] removing getters and setters from couch.py _couch_url was a private variable with getter and setter doing the same as a public variable. It is accessed all over the code, so being private with getters and setters didnt make sense. This commit fixes the tests to also follow this style from now on.
2015-08-26[refactor] Move constructor, use isinstanceVictor Shyba
isinstance is better, as kaliy pointed out, and the constructor is also in a safer place on __init__.py to be explicit. Also re-apply a change from last rebase;
2015-08-26[bug] fixes small issues pointed by drebsVictor Shyba
* file headers * variable names * missing docstrings * prune_conflicts ** extra: tests failed on a 1-based index bug
2015-08-26[bug] check type before processingVictor Shyba
Necessary methods are on CouchDocument, but we accept a Document as well, in this case self._factory is needed. Will be simpler soon.
2015-08-26[refactor] _process_incoming_doc is a function nowVictor Shyba
This was being calculated inside CouchDatabase, but it is not a persistence responsibility. It clearly doesn't belong to this persistence layer and seeing both sides separated allow us to work better on both parts.
2015-08-26[refactor] prune conflicts is Document's responsibilityVictor Shyba
2015-08-26[refactor] simplify conflicts managementVictor Shyba
Adding, removing and checking conflicts is an operation done by the model, the Database shouldn't be aware of that. Fetching and saving also is not model's responsability. Repetition remove as well.
2015-08-26[refactor] remove unused parameterVictor Shyba
2015-08-26[refactor] removing getters and setters from couch.pyVictor Shyba
This is not needed, the behavior under them is the same as an assignment.
2015-08-26[refactor] simplify the case of a brand new docVictor Shyba
If a doc is not present on database at all, it will simply get inserted. This commit makes this clear and skips unnecessary checks.
2015-08-26[refactor] split put_doc_if_newer in two operationsVictor Shyba
Those two operations were mixed on put_doc_if_newer, extracting should make it more clear.
2015-08-25[style] pep8 fixesKali Kaneko
2015-08-24[refactor] remove simplejson dependency on commondrebs
2015-08-24[tests] add sqlite tests to sqlcipherdrebs
Add tests from u1db.tests.test_sqlite_backend.TestSQLitePartialExpandDatabase to soledad sqlcipher tests.
2015-08-24[tests] remove u1db test remote sync target moduledrebs
All tests in that module have been included in soledad's own test modules, so it can be removed so we have less unneeded skipped tests.
2015-08-24[tests] add u1db sync target tests to soledaddrebs
Modify leap.soledad.common.tests.test_sync_target to add: * u1db.tests.test_remote_sync_target.TestRemoteSyncTargets * u1db.tests.test_sync.DatabaseSyncTargetTests
2015-08-24[tests] add missing sync tests to sqlcipherdrebs
Some tests from the original u1db.tests.test_sync.SQLCipherDatabaseSyncTests were missing, this commit adds them back to the soledad sqlcipher tests.
2015-08-20[style] pep8 fixesKali Kaneko
2015-08-20[tests] adapt test for end-of-sync eventdrebs
The soledad sync method was changed to use twisted deferreds, but the test that checks for sync signal was not changed accordingly. This commit fixes that.
2015-08-20[tests] add u1db sync tests to soledad couch testsdrebs
2015-08-20[style] pep8'dKali Kaneko
2015-08-20[tests] add u1db sync tests to sqlcipher's testsdrebs
2015-08-19[style] pep8 cleanupsKali Kaneko
2015-08-19[bug] wait for db init on sync decrypter pooldrebs
Previous to this modification, the initialization of the sync decrypter pool could happen concurrently with other database operations. That could cause the pool to hang because it could be waiting for something that was mistakenly deleted because of the wrong order of database operations. This commit implements a standard which we already use in leap.keymanager and leap.mail which makes some methods wait for the initialization operation before they are actually called. Closes: #7386
2015-08-17[style] pep8 cleanupKali Kaneko
2015-08-17[tests] add mutex sync testsdrebs
2015-08-17[tests] fix test_sqlcipher_syncdrebs
2015-08-17[tests] fix test_sync_deferred testdrebs
* Add possibility of passing sync_db and sync_enc_pool to target creation. * Ensure defer_encryption and defer_decryption are True when setting up the test environment.
2015-08-17[tests] fix tests from test_sync moduledrebs
* Remove test to assert database autocreation. We don't have that feature in soledad and so don't need that test here. * Remove redundant test without token authentication. * Fix server setup. * Skip interruptable sync test case, for now.
2015-08-12[bug] wrong sqlcipher passphrase now raises correctlyBruno Wagner
When you tried to start a local sqlcipher that was created before, with the wrong passphrase, the code was raising a sqlcipher DatabaseError, there were tests covering this but they were expecting a WrongMacError that was never raised. I added code to wrap the DatabaseError and raise a new exception DatabaseAccessError that is specific to soledad and adapted the tests to expect it
2015-08-12[tests] added inlineCallbacks to test with yieldBruno Wagner
test_db_sync_autocreate was using yield but didn't have the inlineCallbacks decorator, that made it a generator but the trial tests don't support generators. Fixed this
2015-08-12[tests] Test encdecpool couldn't resolve inheritanceBruno Wagner
It was inheriting from twisted testcase in both u1db_tests.TestCase and in BaseSoledadTest, removed u1db testcase and everything is ok now
2015-08-12[style] Fixed pep8 warnings after PRBruno Wagner
Fixed pep8 warnings after latest PR
2015-08-12[bug] fix several things on testsdrebs
* redefine the BaseLeapTest class so it inherits from twisted.trial.unittest.TestCase. * allow passing the source_replica_uid when creating the sync target. This is needed because the SoledadHTTPSyncTarget needs to be instantiated with the source_replica_uid passed as a parameter. * close the sync target in tests that use it. * raise and U1DBError instead of an Exception on failure_and_retry test, because otherwise the u1db http app server will re-raise the Exception and twisted's WSGI server will raise the exception * set defer_decryption=False in some sync_exchange() calls so the call is consistent with soledad instantiation in tests and the new signature of that method. * yield get_sync_info() in tests that use this method.
2015-08-12[tests] #7370 opened, skipping test for nowVictor Shyba
While #7370 is being researched, it doesnt make sense to have this test running for now. Will be enabled again after investigation finishes.
2015-08-12[bug] Using lambda to avoid mistake on argumentsVictor Shyba
As suggested by drebs, the callback chaining can put None to sync, bringing undesired behavior.
2015-08-12[tests] Fixed double getURL in some testsBruno Wagner
Some calls to soledad_sync_target were being made with a full path, but the the method itself handles that, so I removed the extraneous calls those problems
2015-08-12[tests] Fixed flakiness in test_sync_targetBruno Wagner
The first test to be run in the TestSoledadParseReceivedDocResponse suite was erroring with connection refused, that is because it actually connects to the server, but wasn't setting it up, I changed it to inherit the simpler SoledadWithCouchServerMixin and adapted the setUp and tearDown, now it works everytime with no problems
2015-08-12[bug] Encdecpool won't explode if stopped twiceBruno Wagner
The encryption pool could be stopped twice and would break on the second attempt because it deletes the encryption queue variable. Added a condition to make sure it only deletes the encryption queue if it exists, making it more idempotent
2015-08-12[tests] Test sync adapted without u1db testsBruno Wagner
Test sync now doesn't inherit from u1db tests, it's tests will now be run and were failing, so I fixed them. Sync deferred will not be correctly handled in these tests. I also pulled over a method from the u1db test and there seems to be a pattern, I'll try to deduplicate these methods as soon as it gets clearer
2015-08-12[tests] Pulled test scenario req into sqlcipher sync testBruno Wagner
Pulled the requirement for the test scenario in sqlcipher sync so we could remove the dependency on the u1db test_sync
2015-08-12[tests] Fixed running sqlcipher_sync testsBruno Wagner
Sqlcipher sync tests were not being run because they were inheriting from a u1db class that was having the tests skipped, I removed that dependency and fixed the tests (they were expecting the synchronous, old http_target api).