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)
    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)
    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)
    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)
    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)
    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)
    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)
    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)
 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)
 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)