Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

initial basic test for generateEmail

  • Loading branch information
glyph committed Aug 12, 2011
1 parent 92247b7 commit 62a4c7c638d31d032cf05abba01742e4bc1279fb
Showing with 44 additions and 16 deletions.
  1. +44 −16 twistedcaldav/test/test_mail.py
@@ -35,6 +35,22 @@
def echo(*args):
return args

initialInviteText = u"""BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
UID:CFDD5E46-4F74-478A-9311-B3FF905449C3
DTSTART:20100325T154500Z
DTEND:20100325T164500Z
ATTENDEE;CN=Th\xe9 Attendee;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:mailto:attendee@example.com
ATTENDEE;CN=Th\xe9 Organizer;CUTYPE=INDIVIDUAL;EMAIL=organizer@example.com;PARTSTAT=ACCEPTED:urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A
ATTENDEE;CN=An Attendee without CUTYPE;EMAIL=nocutype@example.com;PARTSTAT=ACCEPTED:urn:uuid:4DB528DC-3E60-44FA-9546-2A00FCDCFFAB
ATTENDEE;EMAIL=nocn@example.com;PARTSTAT=ACCEPTED:urn:uuid:A592CF8B-4FC8-4E4F-B543-B2F29A7EEB0B
ORGANIZER;CN=Th\xe9 Organizer;EMAIL=organizer@example.com:urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A
SUMMARY:t\xe9sting outbound( )
END:VEVENT
END:VCALENDAR
"""

class MailHandlerTests(TestCase):

@@ -267,22 +283,7 @@ def test_outbound(self):
data = (
# Initial invite
(
u"""BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
UID:CFDD5E46-4F74-478A-9311-B3FF905449C3
DTSTART:20100325T154500Z
DTEND:20100325T164500Z
ATTENDEE;CN=Th\xe9 Attendee;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:mailto:attendee@example.com
ATTENDEE;CN=Th\xe9 Organizer;CUTYPE=INDIVIDUAL;EMAIL=organizer@example.com;PARTSTAT=ACCEPTED:urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A
ATTENDEE;CN=An Attendee without CUTYPE;EMAIL=nocutype@example.com;PARTSTAT=ACCEPTED:urn:uuid:4DB528DC-3E60-44FA-9546-2A00FCDCFFAB
ATTENDEE;EMAIL=nocn@example.com;PARTSTAT=ACCEPTED:urn:uuid:A592CF8B-4FC8-4E4F-B543-B2F29A7EEB0B
ORGANIZER;CN=Th\xe9 Organizer;EMAIL=organizer@example.com:urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A
SUMMARY:t\xe9sting outbound( )
END:VEVENT
END:VCALENDAR
""",
initialInviteText,
"CFDD5E46-4F74-478A-9311-B3FF905449C3",
"urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A",
"mailto:attendee@example.com",
@@ -402,6 +403,33 @@ def test_outbound(self):
self.assertEquals(actualReplyTo, actualFrom)


def test_generateEmail(self):
"""
L{MailHandler.generateEmail} generates a MIME-formatted email with a
text/plain part, a text/html part, and a text/calendar part.
"""
calendar = Component.fromString(initialInviteText)
msgID, msgTxt = self.handler.generateEmail(
inviteState='new',
calendar=calendar,
orgEmail="user01@localhost",
orgCN="User Zero One",
attendees=[("User 1", "user01@localhost"),
("User 2", "user02@localhost")],
fromAddress="user01@localhost",
replyToAddress="imip-system@localhost",
toAddress="user03@localhost",
)
message = email.message_from_string(msgTxt)
self.assertEquals(message['Message-ID'], msgID)
expectedTypes = set(["text/plain", "text/html", "text/calendar"])
actualTypes = set([
part.get_content_type() for part in message.walk()
if not part.get_content_type().startswith("multipart/")
])
self.assertEquals(actualTypes, expectedTypes)


class MailGatewayTokensDatabaseTests(TestCase):

def setUp(self):

0 comments on commit 62a4c7c

Please sign in to comment.
You can’t perform that action at this time.