diff options
author | Ruben Pollan <meskio@sindominio.net> | 2015-02-18 10:24:03 -0600 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2015-02-18 17:30:29 -0600 |
commit | 87c15e3ec5c1ca607890bf72b0d90bb0f114cbb1 (patch) | |
tree | c9e67a7f717367a1e5711f2d50d43d09fb7f2124 /src/leap/mail/incoming/tests | |
parent | d7177ea01c968e5ee221aae90eb6e1f815c09972 (diff) |
Add callbacks to inbox insertions
Diffstat (limited to 'src/leap/mail/incoming/tests')
-rw-r--r-- | src/leap/mail/incoming/tests/test_incoming_mail.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/leap/mail/incoming/tests/test_incoming_mail.py b/src/leap/mail/incoming/tests/test_incoming_mail.py index 0b1e696..a932a95 100644 --- a/src/leap/mail/incoming/tests/test_incoming_mail.py +++ b/src/leap/mail/incoming/tests/test_incoming_mail.py @@ -95,7 +95,8 @@ subject: independence of cyberspace ADDRESS) # The messages don't exist on soledad will fail on deletion - self.fetcher._delete_incoming_message = Mock(return_value=None) + self.fetcher._delete_incoming_message = Mock( + return_value=defer.succeed(None)) d = super(IncomingMailTestCase, self).setUp() d.addCallback(getInbox) @@ -165,12 +166,13 @@ subject: independence of cyberspace message.attach(key) self.fetcher._keymanager.put_raw_key = Mock( return_value=defer.succeed(None)) + self.fetcher._keymanager.fetch_key = Mock() def put_raw_key_called(_): self.fetcher._keymanager.put_raw_key.assert_called_once_with( KEY, OpenPGPKey, address=ADDRESS_2) - d = self._mock_fetch(message.as_string()) + d = self._do_fetch(message.as_string()) d.addCallback(put_raw_key_called) return d @@ -205,12 +207,24 @@ subject: independence of cyberspace d.addCallback(create_encrypted_message) d.addCallback( lambda message: - self._mock_fetch(message.as_string())) + self._do_fetch(message.as_string())) + return d + + def testListener(self): + self.called = False + def listener(uid): + self.called = True + + def listener_called(_): + self.assertTrue(self.called) + + self.fetcher.add_listener(listener) + d = self._do_fetch(self.EMAIL) + d.addCallback(listener_called) return d - def _mock_fetch(self, message): - self.fetcher._keymanager.fetch_key = Mock() + def _do_fetch(self, message): d = self._create_incoming_email(message) d.addCallback( lambda email: |