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', ''))
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', '*****@*****.**'))
def test_domain_name_eq_unicode(self): addr = account.Address('user', 'éxample.com') self.assertEqual(addr, 'user@Éxample.com')
def test_domain_name_eq_case(self): addr = account.Address('user', 'example.com') self.assertEqual(addr, '*****@*****.**')
def test_domain_name_ne(self): addr = account.Address('user', 'example.com') self.assertNotEqual(addr, '*****@*****.**')
def test_domain_name_eq_case_sensitive(self): addr = account.Address(u'user', u'example.com', case_sensitive=True) self.assertEqual(addr, u'*****@*****.**')
def test_ne_unicode_case(self): addr = account.Address('ušer', 'example.com') self.assertEqual(addr, 'uŠ[email protected]')
def test_str(self): addr = account.Address('ušer', 'example.com') self.assertEqual(str(addr), 'uš[email protected]')
def test_eq_unicode_case(self): addr = account.Address(u'UŠer', u'example.com') self.assertEqual(addr, u'uš[email protected]')
def test_ne_unicode(self): addr = account.Address(u'ušer', u'example.com') self.assertNotEqual(addr, u'*****@*****.**')
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)
def test_str(self): addr = account.Address(u'ušer', u'example.com') self.assertEqual(str(addr), u'uš[email protected]'.encode('utf-8'))
def test_unicode(self): addr = account.Address(u'ušer', u'example.com') self.assertEqual(unicode(addr), u'uš[email protected]')
def test_constructor_bytes(self): with self.assertRaises(AssertionError): account.Address(b'username', b'domainname')
def test_domain_name_eq_unicode_sensitive(self): addr = account.Address('user', 'éxample.com', case_sensitive=True) self.assertEqual(addr, 'user@Éxample.com')
def test_cmp_empty(self): addr = account.Address('user', 'éxample.com') self.assertNotEqual(addr, '')
def test_eq_unicode_case_sensitive(self): addr = account.Address('UŠer', 'example.com', case_sensitive=True) self.assertNotEqual(addr, 'uš[email protected]')
def test_ne_address(self): addr = account.Address('ušer', 'example.com') addr2 = account.Address('user', 'example.com') self.assertNotEqual(addr, addr2)
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)
def test_eq_address_case(self): addr = account.Address('UŠer', 'example.com') addr2 = account.Address('ušer', 'example.com') self.assertEqual(addr, addr2)
def test_ne_str(self): addr = account.Address('user', 'example.com', case_sensitive=True) with self.assertRaises(TypeError): addr != 1 # pylint: disable=pointless-statement
def test_repr(self): addr = account.Address('user', 'example.com', case_sensitive=True) self.assertEqual( repr(addr), "Address('user', 'example.com', case_sensitive=True)")
def test_domain_name_ne_unicode(self): addr = account.Address(u'user', u'éxample.com') self.assertNotEqual(addr, u'*****@*****.**')