diff options
author | drebs <drebs@leap.se> | 2016-05-07 17:11:41 -0300 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2016-06-06 20:09:20 -0400 |
commit | 4a1b8f2467a73a9c9a80acf19383786aa188042b (patch) | |
tree | 2b154c040d382225de00459c8d6f33803514cc26 /common | |
parent | ef7aabde344371882b38eacca7294727f6ccaca0 (diff) |
[test] use inline deferreds in test for change passphrase
Diffstat (limited to 'common')
-rw-r--r-- | common/src/leap/soledad/common/tests/test_soledad.py | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/common/src/leap/soledad/common/tests/test_soledad.py b/common/src/leap/soledad/common/tests/test_soledad.py index b48915eb..aa52a733 100644 --- a/common/src/leap/soledad/common/tests/test_soledad.py +++ b/common/src/leap/soledad/common/tests/test_soledad.py @@ -100,6 +100,7 @@ class AuxMethodsTestCase(BaseSoledadTest): self.assertEqual('value_1', sol._server_url) sol.close() + @defer.inlineCallbacks def test_change_passphrase(self): """ Test if passphrase can be changed. @@ -111,38 +112,25 @@ class AuxMethodsTestCase(BaseSoledadTest): prefix=prefix, ) - def _change_passphrase(doc1): - self._doc1 = doc1 - sol.change_passphrase(u'654321') - sol.close() - - def _assert_wrong_password_raises(results): - with self.assertRaises(DatabaseAccessError): - self._soledad_instance( - 'leap@leap.se', - passphrase=u'123', - prefix=prefix) + doc1 = yield sol.create_doc({'simple': 'doc'}) + sol.change_passphrase(u'654321') + sol.close() - def _instantiate_with_new_passphrase(results): - sol2 = self._soledad_instance( + with self.assertRaises(DatabaseAccessError): + self._soledad_instance( 'leap@leap.se', - passphrase=u'654321', + passphrase=u'123', prefix=prefix) - self._sol2 = sol2 - return sol2.get_doc(self._doc1.doc_id) - def _assert_docs_are_equal(doc2): - self.assertEqual(self._doc1, doc2) - self._sol2.close() + sol2 = self._soledad_instance( + 'leap@leap.se', + passphrase=u'654321', + prefix=prefix) + doc2 = yield sol2.get_doc(doc1.doc_id) - d = sol.create_doc({'simple': 'doc'}) - d.addCallback(_change_passphrase) - d.addCallback(_assert_wrong_password_raises) - d.addCallback(_instantiate_with_new_passphrase) - d.addCallback(_assert_docs_are_equal) - d.addCallback(lambda _: sol.close()) + self.assertEqual(doc1, doc2) - return d + sol2.close() def test_change_passphrase_with_short_passphrase_raises(self): """ |