Example #1
0
 def test_get_author_no_name(self):
     """Message._from is set to 'Unkown' if there is no relavent header and
     the message is not a draft.
     """
     acc = mock.Mock()
     acc.address = account.Address(u'user', u'example.com')
     acc.realname = u'User Name'
     with mock.patch('alot.db.message.settings.get_accounts',
                     mock.Mock(return_value=[acc])):
         msg = message.Message(mock.Mock(), MockNotmuchMessage())
     self.assertEqual(msg.get_author(), ('Unknown', ''))
Example #2
0
 def test_get_author_no_name_draft(self):
     """Message._from is populated from the default account if the draft tag
     is present.
     """
     acc = mock.Mock()
     acc.address = account.Address(u'user', u'example.com')
     acc.realname = u'User Name'
     with mock.patch('alot.db.message.settings.get_accounts',
                     mock.Mock(return_value=[acc])):
         msg = message.Message(mock.Mock(),
                               MockNotmuchMessage(tags=['draft']))
     self.assertEqual(msg.get_author(), ('User Name', '*****@*****.**'))
Example #3
0
 def test_domain_name_eq_unicode(self):
     addr = account.Address('user', 'éxample.com')
     self.assertEqual(addr, 'user@Éxample.com')
Example #4
0
 def test_domain_name_eq_case(self):
     addr = account.Address('user', 'example.com')
     self.assertEqual(addr, '*****@*****.**')
Example #5
0
 def test_domain_name_ne(self):
     addr = account.Address('user', 'example.com')
     self.assertNotEqual(addr, '*****@*****.**')
Example #6
0
 def test_domain_name_eq_case_sensitive(self):
     addr = account.Address(u'user', u'example.com', case_sensitive=True)
     self.assertEqual(addr, u'*****@*****.**')
Example #7
0
 def test_ne_unicode_case(self):
     addr = account.Address('ušer', 'example.com')
     self.assertEqual(addr, 'uŠ[email protected]')
Example #8
0
 def test_str(self):
     addr = account.Address('ušer', 'example.com')
     self.assertEqual(str(addr), 'uš[email protected]')
Example #9
0
 def test_eq_unicode_case(self):
     addr = account.Address(u'UŠer', u'example.com')
     self.assertEqual(addr, u'uš[email protected]')
Example #10
0
 def test_ne_unicode(self):
     addr = account.Address(u'ušer', u'example.com')
     self.assertNotEqual(addr, u'*****@*****.**')
Example #11
0
 def test_eq_address(self):
     addr = account.Address(u'ušer', u'example.com')
     addr2 = account.Address(u'ušer', u'example.com')
     self.assertEqual(addr, addr2)
Example #12
0
 def test_str(self):
     addr = account.Address(u'ušer', u'example.com')
     self.assertEqual(str(addr), u'uš[email protected]'.encode('utf-8'))
Example #13
0
 def test_unicode(self):
     addr = account.Address(u'ušer', u'example.com')
     self.assertEqual(unicode(addr), u'uš[email protected]')
Example #14
0
 def test_constructor_bytes(self):
     with self.assertRaises(AssertionError):
         account.Address(b'username', b'domainname')
Example #15
0
 def test_domain_name_eq_unicode_sensitive(self):
     addr = account.Address('user', 'éxample.com', case_sensitive=True)
     self.assertEqual(addr, 'user@Éxample.com')
Example #16
0
 def test_cmp_empty(self):
     addr = account.Address('user', 'éxample.com')
     self.assertNotEqual(addr, '')
Example #17
0
 def test_eq_unicode_case_sensitive(self):
     addr = account.Address('UŠer', 'example.com', case_sensitive=True)
     self.assertNotEqual(addr, 'uš[email protected]')
Example #18
0
 def test_ne_address(self):
     addr = account.Address('ušer', 'example.com')
     addr2 = account.Address('user', 'example.com')
     self.assertNotEqual(addr, addr2)
Example #19
0
 def test_eq_address_case_sensitive(self):
     addr = account.Address('UŠer', 'example.com', case_sensitive=True)
     addr2 = account.Address('ušer', 'example.com')
     self.assertNotEqual(addr, addr2)
Example #20
0
 def test_eq_address_case(self):
     addr = account.Address('UŠer', 'example.com')
     addr2 = account.Address('ušer', 'example.com')
     self.assertEqual(addr, addr2)
Example #21
0
 def test_ne_str(self):
     addr = account.Address('user', 'example.com', case_sensitive=True)
     with self.assertRaises(TypeError):
         addr != 1  # pylint: disable=pointless-statement
Example #22
0
 def test_repr(self):
     addr = account.Address('user', 'example.com', case_sensitive=True)
     self.assertEqual(
         repr(addr), "Address('user', 'example.com', case_sensitive=True)")
Example #23
0
 def test_domain_name_ne_unicode(self):
     addr = account.Address(u'user', u'éxample.com')
     self.assertNotEqual(addr, u'*****@*****.**')