Example #1
0
 def test_get_author_email_only(self):
     """Message._from is populated using the 'From' header when only an
     email address is provided.
     """
     msg = message.Message(mock.Mock(),
                           MockNotmuchMessage({'From': '*****@*****.**'}))
     self.assertEqual(msg.get_author(), ('', '*****@*****.**'))
Example #2
0
 def test_get_author_sender(self):
     """Message._from is populated using the 'Sender' header when no 'From'
     header is present.
     """
     msg = message.Message(
         mock.Mock(),
         MockNotmuchMessage({'Sender': '"User Name" <*****@*****.**>'}))
     self.assertEqual(msg.get_author(), ('User Name', '*****@*****.**'))
Example #3
0
 def test_get_author_name_and_email(self):
     """Message._from is populated using the 'From' header when an email and
     name are provided.
     """
     msg = message.Message(
         mock.Mock(),
         MockNotmuchMessage({'From': '"User Name" <*****@*****.**>'}))
     self.assertEqual(msg.get_author(), ('User Name', '*****@*****.**'))
Example #4
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 #5
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', '*****@*****.**'))