Ejemplo n.º 1
0
    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())
Ejemplo n.º 2
0
    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())
Ejemplo n.º 3
0
 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')
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 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")
Ejemplo n.º 6
0
 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')
Ejemplo n.º 7
0
 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')
Ejemplo n.º 8
0
    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')
Ejemplo n.º 9
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)
Ejemplo n.º 10
0
    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')
Ejemplo n.º 11
0
 def test_isvalid_whitelist_skip(self):
     self.config['accept_whitelist_only'] = False
     self.assertTrue(self.distributor._isvalid(load_msg('sample7')))
Ejemplo n.º 12
0
 def test_isvalid_false(self):
     self.assertFalse(self.distributor._isvalid(load_msg('sample7')))
Ejemplo n.º 13
0
 def test_isvalid_blacklist(self):
     self.assertFalse(self.distributor._isvalid(load_msg('sample9')))
Ejemplo n.º 14
0
 def test_isvalid_whitelist(self):
     self.assertTrue(self.distributor._isvalid(load_msg('sample8')))
Ejemplo n.º 15
0
 def test_isvalid_whitelist(self):
     self.assertTrue(self.distributor._isvalid(load_msg('sample8')))
Ejemplo n.º 16
0
 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é:'])
Ejemplo n.º 17
0
    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)
Ejemplo n.º 18
0
 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é:'])
Ejemplo n.º 19
0
 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é:'])
Ejemplo n.º 20
0
 def test_isvalid_whitelist_skip(self):
     self.config['accept_whitelist_only'] = False
     self.assertTrue(self.distributor._isvalid(load_msg('sample7')))
Ejemplo n.º 21
0
 def test_isvalid_false(self):
     self.assertFalse(self.distributor._isvalid(load_msg('sample7')))
Ejemplo n.º 22
0
 def test_isvalid_blacklist(self):
     self.assertFalse(self.distributor._isvalid(load_msg('sample9')))
Ejemplo n.º 23
0
 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é:'])
Ejemplo n.º 24
0
    def test_update_blacklisted_message(self):
        self._update_with(load_msg('sample9'))

        self._check_start_stop()
        self._check_interactions()
Ejemplo n.º 25
0
    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)
Ejemplo n.º 26
0
    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)
Ejemplo n.º 27
0
    def test_update_invalid_message(self):
        self._update_with(load_msg('sample7'))

        self._check_start_stop()
        self._check_interactions()
Ejemplo n.º 28
0
    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)
Ejemplo n.º 29
0
    def test_update_blacklisted_message(self):
        self._update_with(load_msg('sample9'))

        self._check_start_stop()
        self._check_interactions()
Ejemplo n.º 30
0
    def test_update_invalid_message(self):
        self._update_with(load_msg('sample7'))

        self._check_start_stop()
        self._check_interactions()