Exemplo n.º 1
0
class ListEmailCommandTest(TestCase):
    def setUp(self):
        self.command = ListEmailCommand()

    def test_invoke_should_format_mail_summaries(self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject='Test', sender='*****@*****.**', guid='1234567', datetime=date)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal('(*) 1234567   12:34:00  [email protected]\nTest\n\n')

    def test_invoke_should_format_mail_summaries_without_star_when_read(self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject='Test', sender='*****@*****.**', guid='1234567', datetime=date, read=True)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal('( ) 1234567   12:34:00  [email protected]\nTest\n\n')

    def test_invoke_should_format_mail_summaries_with_left_aligned_guid(self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject='Test', sender='*****@*****.**', guid='123', datetime=date)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal('(*) 123       12:34:00  [email protected]\nTest\n\n')

    def test_invoke_should_format_mail_summaries_with_min_two_spaces_after_guid(self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject='Test', sender='*****@*****.**', guid='1234567890', datetime=date)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal('(*) 1234567890  12:34:00  [email protected]\nTest\n\n')

    def test_invoke_should_handle_unicode_chars(self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject=u'Test\u0131', sender='*****@*****.**', guid='1234567', datetime=date)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal(u'(*) 1234567   12:34:00  [email protected]\nTest\u0131\n\n')

    def test_invoke_should_format_mail_summaries_with_tz_when_present(self):
        date = datetime(2014, 2, 16, 12, 34, tzinfo=utc)
        mail = Mail(subject='Test', sender='*****@*****.**', guid='1234567', datetime=date, read=True)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal('( ) 1234567   12:34:00+00:00  [email protected]\nTest\n\n')
Exemplo n.º 2
0
 def setUp(self):
     self.command = ListEmailCommand()
Exemplo n.º 3
0
 def setUp(self):
     self.command = ListEmailCommand()
Exemplo n.º 4
0
class ListEmailCommandTest(TestCase):
    def setUp(self):
        self.command = ListEmailCommand()

    def test_invoke_should_format_mail_summaries(self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject='Test',
                    sender='*****@*****.**',
                    guid='1234567',
                    datetime=date)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal(
            '(*) 1234567   12:34:00  [email protected]\nTest\n\n')

    def test_invoke_should_format_mail_summaries_without_star_when_read(self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject='Test',
                    sender='*****@*****.**',
                    guid='1234567',
                    datetime=date,
                    read=True)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal(
            '( ) 1234567   12:34:00  [email protected]\nTest\n\n')

    def test_invoke_should_format_mail_summaries_with_left_aligned_guid(self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject='Test',
                    sender='*****@*****.**',
                    guid='123',
                    datetime=date)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal(
            '(*) 123       12:34:00  [email protected]\nTest\n\n')

    def test_invoke_should_format_mail_summaries_with_min_two_spaces_after_guid(
            self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject='Test',
                    sender='*****@*****.**',
                    guid='1234567890',
                    datetime=date)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal(
            '(*) 1234567890  12:34:00  [email protected]\nTest\n\n')

    def test_invoke_should_handle_unicode_chars(self):
        date = datetime(2014, 2, 16, 12, 34)
        mail = Mail(subject=u'Test\u0131',
                    sender='*****@*****.**',
                    guid='1234567',
                    datetime=date)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal(
            u'(*) 1234567   12:34:00  [email protected]\nTest\u0131\n\n')

    def test_invoke_should_format_mail_summaries_with_tz_when_present(self):
        date = datetime(2014, 2, 16, 12, 34, tzinfo=utc)
        mail = Mail(subject='Test',
                    sender='*****@*****.**',
                    guid='1234567',
                    datetime=date,
                    read=True)
        mock_session = Mock(get_email_list=lambda: [mail])
        output = self.command.invoke(mock_session, None)
        expect(output).to.equal(
            '( ) 1234567   12:34:00+00:00  [email protected]\nTest\n\n')