Exemplo n.º 1
0
class ContactTest:
    def setUp(self):  # NOQA
        self.contact = Contact('James Rowe', '*****@*****.**', 200)

    def test___repr__(self):
        expect(repr(self.contact)) == \
            "Contact('James Rowe', ['*****@*****.**'], 200)"

    def test___str__(self):
        expect(str(self.contact)) == \
            'James Rowe <*****@*****.**> (200 days)'
        expect(str(Contact(
            'James Rowe', ['*****@*****.**', '*****@*****.**'],
            200))) == \
            'James Rowe <[email protected], [email protected]> (200 days)'

    def test___format__(self):
        expect(format(self.contact)) == \
            'James Rowe <*****@*****.**> (200 days)'
        expect(format(self.contact, 'email')) == \
            'James Rowe <*****@*****.**>'
        expect(format(Contact, 'email'(
            'James Rowe', ['*****@*****.**', '*****@*****.**'],
            200))) == \
            'James Rowe <*****@*****.**>'

    def trigger(self, sent):
        expect(self.contact.trigger({
            '*****@*****.**': date(1942, 1, 1)}
        )) == date(1942, 7, 20)

    @patch('blanco.pynotify')
    def notify_str(self, pynotify):
        pynotify.get_server_caps.return_value = []
        expect(self.contact.notify_str()) == 'James Rowe'
        pynotify.get_server_caps.return_value = ['body-hyperlinks', ]
        expect(self.contact.notify_str()) == \
            "<a href='mailto:[email protected]'>James Rowe</a>"
Exemplo n.º 2
0
 def setUp(self):  # NOQA
     self.contact = Contact('James Rowe', '*****@*****.**', 200)