def test_update_multiple_messages(self): messages = { 1237 : self.msg, 1238 : load_msg('sample3'), 1239 : load_msg('sample5') } self.reader.new_messages.return_value = messages.keys() self.reader.get.side_effect = lambda id : messages[id] self.assertTrue(self.distributor.update()) self._check_start_stop() self._check_interactions(*messages.keys()) self._check_archived(*messages.values())
def test_update_multiple_messages(self): messages = { 1237: self.msg, 1238: load_msg('sample3'), 1239: load_msg('sample5') } self.reader.new_messages.return_value = messages.keys() self.reader.get.side_effect = lambda id: messages[id] self.assertTrue(self.distributor.update()) self._check_start_stop() self._check_interactions(*messages.keys()) self._check_archived(*messages.values())
def setUp(self): super(OfflineDistributeTest, self).setUp() self.distributor = OfflineDistributor(self.config) self.sender = Mock(spec=Sender) self.distributor._sender = self.sender self.store = self.distributor._store self.msg = load_msg('sample')
def test_edit_msg_anonymize(self): with_emails = load_msg('sample3') self.distributor._edit_msg(with_emails) texts = [msg.get_payload(decode=True) for msg in with_emails.get_payload()] for text in texts: self.assertTrue('sender@' in text) self.assertFalse('@host.com' in text)
def setUp(self): super(OfflineDistributeTest, self).setUp() self.distributor = OfflineDistributor(self.config) self.sender = Mock(spec=Sender) self.distributor._sender = self.sender self.store = self.distributor._store self.msg = load_msg("sample")
def setUp(self): super(OnlineDownloadDistributeTest, self).setUp() self.distributor = OnlineDistributor(self.config) self.sender = Mock(spec=Sender) self.distributor._sender = self.sender self.reader = Mock(spec=Reader) self.distributor._reader = self.reader self.msg = load_msg('sample10')
def setUp(self): super(OnlineDistributeTest,self).setUp() self.distributor = OnlineDistributor(self.config) self.sender = Mock(spec=Sender) self.distributor._sender = self.sender self.reader = Mock(spec=Reader) self.distributor._reader = self.reader self.msg = load_msg('sample')
def test_send(self, smtp, sendmail): msg = load_msg('sample') self.sender.send(msg, u'*****@*****.**') self.assertEqual(sendmail.call_count, 1) self.assertEqual(msg['To'], u'*****@*****.**') self.assertEqual(msg['From'], self.sender.get_address()) self.assertEqual(msg['Reply-To'], self.sender.get_address()) self.assertEqual(msg['Subject'], u'[Test] BETA 2.0')
def test_edit_msg_anonymize(self): with_emails = load_msg('sample3') self.distributor._edit_msg(with_emails) texts = [ msg.get_payload(decode=True) for msg in with_emails.get_payload() ] for text in texts: self.assertTrue('sender@' in text) self.assertFalse('@host.com' in text)
def test_isvalid_whitelist_skip(self): self.config['accept_whitelist_only'] = False self.assertTrue(self.distributor._isvalid(load_msg('sample7')))
def test_isvalid_false(self): self.assertFalse(self.distributor._isvalid(load_msg('sample7')))
def test_isvalid_blacklist(self): self.assertFalse(self.distributor._isvalid(load_msg('sample9')))
def test_isvalid_whitelist(self): self.assertTrue(self.distributor._isvalid(load_msg('sample8')))
def test_create_header_non_member(self): simple_sender = load_msg('sample8') self.config['introductions'] = [ u'salté' ] self.assertEqual(self.distributor._create_header(simple_sender), [u'whitelist salté:'])
def test_update_whitelisted_message(self): msg = self._update_with(load_msg('sample8')) self._check_start_stop() self._check_interactions(1237) self._check_archived(msg)
def test_create_header_non_member(self): simple_sender = load_msg('sample8') self.config['introductions'] = [u'salté'] self.assertEqual(self.distributor._create_header(simple_sender), [u'whitelist salté:'])
def test_create_header_special_chars(self): simple_sender = load_msg('sample2') self.config['introductions'] = [u'salté'] self.assertEqual(self.distributor._create_header(simple_sender), [u'MIA salté:'])
def test_create_header_special_chars(self): simple_sender = load_msg('sample2') self.config['introductions'] = [ u'salté' ] self.assertEqual(self.distributor._create_header(simple_sender), [u'MIA salté:'])
def test_update_blacklisted_message(self): self._update_with(load_msg('sample9')) self._check_start_stop() self._check_interactions()
def test_update_message_without_subject(self): msg = self._update_with(load_msg('sample13')) self._check_start_stop() self._check_interactions(1237) self._check_archived(msg)
def test_update_invalid_message(self): self._update_with(load_msg('sample7')) self._check_start_stop() self._check_interactions()