diff options
author | drebs <drebs@leap.se> | 2015-08-20 16:08:53 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2015-08-20 16:09:58 -0300 |
commit | c050a98302f07eac99cf2576750878b2417cff15 (patch) | |
tree | a535195b1cd1bc5a204a0abfea6dc57d59d2eebc | |
parent | 1da0dcad540a05828437b2ba0ead617ac40aeccc (diff) |
[tests] adapt test for end-of-sync event
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.
-rw-r--r-- | common/src/leap/soledad/common/tests/test_soledad.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/common/src/leap/soledad/common/tests/test_soledad.py b/common/src/leap/soledad/common/tests/test_soledad.py index c8bcaba1..bd356858 100644 --- a/common/src/leap/soledad/common/tests/test_soledad.py +++ b/common/src/leap/soledad/common/tests/test_soledad.py @@ -18,8 +18,11 @@ Tests for general Soledad functionality. """ import os + from mock import Mock +from twisted.internet import defer + from leap.common.events import catalog from leap.soledad.common.tests.util import ( BaseSoledadTest, @@ -348,26 +351,26 @@ class SoledadSignalingTestCase(BaseSoledadTest): self.assertEqual([], soledad.client.signal.mock_calls) sol.close() + @defer.inlineCallbacks def test_sync_signals(self): """ Test Soledad emits SOLEDAD_CREATING_KEYS signal. """ - soledad.client.signal.reset_mock() # get a fresh instance so it emits all bootstrap signals sol = self._soledad_instance() + soledad.client.signal.reset_mock() + # mock the actual db sync so soledad does not try to connect to the # server - sol._dbsyncer.sync = Mock() - - def _assert_done_data_sync_signal_emitted(results): - # assert the signal has been emitted - soledad.client.events.emit.assert_called_with( - catalog.SOLEDAD_DONE_DATA_SYNC, - ADDRESS, - ) - sol.close() + d = defer.Deferred() + d.callback(None) + sol._dbsyncer.sync = Mock(return_value=d) - # do the sync and assert signal was emitted - d = sol.sync() - d.addCallback(_assert_done_data_sync_signal_emitted) - return d + yield sol.sync() + + # assert the signal has been emitted + soledad.client.events.emit.assert_called_with( + catalog.SOLEDAD_DONE_DATA_SYNC, + ADDRESS, + ) + sol.close() |