Пример #1
0
    def test_to_header_from_addresses_single(self):
        'Ensure we handle a single to-addresses correctly'
        addr = ['*****@*****.**', ]
        toUserInfo = MagicMock()
        toUserInfo.name = 'Example Person'
        ms = MessageSender(MagicMock(), toUserInfo)
        r = ms.to_header_from_addresses(addr)

        self.assertEqual('Example Person <*****@*****.**>', r)
Пример #2
0
    def test_to_header_from_addresses_none(self, m_t_a):
        'Ensure we used the default address if we are given no address'
        m_t_a.return_value = ['*****@*****.**', ]
        toUserInfo = MagicMock()
        toUserInfo.name = 'Example Person'
        ms = MessageSender(MagicMock(), toUserInfo)
        r = ms.to_header_from_addresses(None)

        self.assertEqual('Example Person <*****@*****.**>', r)
Пример #3
0
    def test_to_header_from_addresses_multiple(self):
        'Ensure we handle multiple to-addresses correctly'
        addr = ['*****@*****.**', '*****@*****.**', ]
        toUserInfo = MagicMock()
        toUserInfo.name = 'Example Person'
        ms = MessageSender(MagicMock(), toUserInfo)
        r = ms.to_header_from_addresses(addr)

        expected = 'Example Person <*****@*****.**>, Example Person <*****@*****.**>'
        self.assertEqual(expected, r)
Пример #4
0
    def test_to_header_from_addresses_none_multiple(self, m_t_a):
        'Ensure we handle multiple to-addresses correctly if they are the default'
        m_t_a.return_value = ['*****@*****.**', '*****@*****.**', ]
        toUserInfo = MagicMock()
        toUserInfo.name = 'Example Person'
        ms = MessageSender(MagicMock(), toUserInfo)
        r = ms.to_header_from_addresses(None)

        expected = 'Example Person <*****@*****.**>, Example Person <*****@*****.**>'
        self.assertEqual(expected, r)
Пример #5
0
    def test_to_header_from_addresses_single(self):
        'Ensure we handle a single to-addresses correctly'
        addr = [
            '*****@*****.**',
        ]
        toUserInfo = MagicMock()
        toUserInfo.name = 'Example Person'
        ms = MessageSender(MagicMock(), toUserInfo)
        r = ms.to_header_from_addresses(addr)

        self.assertEqual('Example Person <*****@*****.**>', r)
Пример #6
0
    def test_to_header_from_addresses_none(self, m_t_a):
        'Ensure we used the default address if we are given no address'
        m_t_a.return_value = [
            '*****@*****.**',
        ]
        toUserInfo = MagicMock()
        toUserInfo.name = 'Example Person'
        ms = MessageSender(MagicMock(), toUserInfo)
        r = ms.to_header_from_addresses(None)

        self.assertEqual('Example Person <*****@*****.**>', r)
Пример #7
0
    def test_to_header_from_addresses_multiple(self):
        'Ensure we handle multiple to-addresses correctly'
        addr = [
            '*****@*****.**',
            '*****@*****.**',
        ]
        toUserInfo = MagicMock()
        toUserInfo.name = 'Example Person'
        ms = MessageSender(MagicMock(), toUserInfo)
        r = ms.to_header_from_addresses(addr)

        expected = 'Example Person <*****@*****.**>, Example Person <*****@*****.**>'
        self.assertEqual(expected, r)
Пример #8
0
    def test_to_header_from_addresses_none_multiple(self, m_t_a):
        'Ensure we handle multiple to-addresses correctly if they are the default'
        m_t_a.return_value = [
            '*****@*****.**',
            '*****@*****.**',
        ]
        toUserInfo = MagicMock()
        toUserInfo.name = 'Example Person'
        ms = MessageSender(MagicMock(), toUserInfo)
        r = ms.to_header_from_addresses(None)

        expected = 'Example Person <*****@*****.**>, Example Person <*****@*****.**>'
        self.assertEqual(expected, r)
Пример #9
0
 def test_to_header_from_addresses_issues(self, m_t_a):
     'Test we raise a ValueError if we lack and address to send to'
     m_t_a.return_value = None
     ms = MessageSender(MagicMock(), MagicMock())
     with self.assertRaises(ValueError):
         ms.to_header_from_addresses(None)
Пример #10
0
 def test_to_header_from_addresses_issues(self, m_t_a):
     'Test we raise a ValueError if we lack and address to send to'
     m_t_a.return_value = None
     ms = MessageSender(MagicMock(), MagicMock())
     with self.assertRaises(ValueError):
         ms.to_header_from_addresses(None)