Commit by: bkirsch
Modified files:
chandler/parcels/osaf/contentmodel/tests/GenerateItems.py 1.27 1.28

Log message:
Adds mail message creation to Generate Test menus. Fixes bug #2610 -r Bryan 
Stearns

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/contentmodel/tests/GenerateItems.py.diff?r1=text&tr1=1.27&r2=text&tr2=1.28

Index: chandler/parcels/osaf/contentmodel/tests/GenerateItems.py
diff -u chandler/parcels/osaf/contentmodel/tests/GenerateItems.py:1.27 
chandler/parcels/osaf/contentmodel/tests/GenerateItems.py:1.28
--- chandler/parcels/osaf/contentmodel/tests/GenerateItems.py:1.27      Wed Feb 
23 11:12:41 2005
+++ chandler/parcels/osaf/contentmodel/tests/GenerateItems.py   Thu Mar 10 
11:08:01 2005
@@ -2,8 +2,8 @@
 Generate sample items: calendar, contacts, etc.
 """
 
-__revision__  = "$Revision: 1.27 $"
-__date__      = "$Date: 2005/02/23 19:12:41 $"
+__revision__  = "$Revision: 1.28 $"
+__date__      = "$Date: 2005/03/10 19:08:01 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm";
 
@@ -34,6 +34,8 @@
 IMPORTANCE = ["important", "normal", "fyi"]
 LOCATIONS  = ["Home", "Office", "School"]
 
+
+
 def GenerateCalendarEvent(view, days=30):
     event = Calendar.CalendarEvent(view=view)
     event.displayName = random.choice(HEADLINES)
@@ -61,12 +63,60 @@
 
     event.importance = random.choice(IMPORTANCE)
     return event
-    
+
 
 TITLES = ["reading list", "restaurant recommendation", "vacation ideas",
           "grocery list", "gift ideas", "life goals", "fantastic recipe",
           "garden plans", "funny joke", "story idea", "poem"]
 
+EVENT, TASK, BOTH = range(2, 5)
+M_TEXT  = "This is a test email message"
+M_EVENT = " that has been stamped as a Calendar Event"
+M_TASK  = " that has been stamped as a Task"
+M_BOTH  = " that has been stamped as a Task and a Calendar Event"
+
+def GenerateMailMessage(view):
+    message  = Mail.MailMessage(view=view)
+    body     = M_TEXT
+
+    outbound = random.randint(0, 1)
+    type     = random.randint(1, 8)
+    numTo    = random.randint(1, 3)
+
+    message.fromAddress = GenerateCalendarParticipant(view)
+
+    for num in range(numTo):
+        message.toAddress.append(GenerateCalendarParticipant(view))
+
+    message.subject  = random.choice(TITLES)
+    message.dateSent = DateTime.now()
+
+    if outbound:
+        message.outgoingMessage()
+
+        """Make the Message appear as if it has already been sent"""
+        message.deliveryExtension.sendSucceeded()
+
+    else:
+        message.incomingMessage()
+
+    if type == EVENT:
+        message.StampKind('add', 
Calendar.CalendarEventMixin.getKind(message.itsView))
+        body += M_EVENT
+
+    if type == TASK:
+        message.StampKind('add', Task.TaskMixin.getKind(message.itsView))
+        body += M_TASK
+
+    if type == BOTH:
+        message.StampKind('add', Task.TaskMixin.getKind(message.itsView))
+        message.StampKind('add', 
Calendar.CalendarEventMixin.getKind(message.itsView))
+        body += M_BOTH
+
+    message.body = message.getAttributeAspect('body', 'type').makeValue(body)
+
+    return message
+
 def GenerateNote(view):
     """ Generate one Note item """
     note = Notes.Note(view=view)
@@ -206,7 +256,7 @@
     existingNames = sidebarCollection is not None and [ 
existingCollection.displayName for existingCollection in sidebarCollection] or 
[]
     collections = GenerateItems(view, 5, GenerateCollection, [], mainView, 
existingNames)
     
-    for fn in GenerateNote, GenerateCalendarEvent, GenerateTask, 
GenerateEventTask: # GenerateContact omitted.
+    for fn in GenerateMailMessage, GenerateNote, GenerateCalendarEvent, 
GenerateTask, GenerateEventTask: # GenerateContact omitted.
         GenerateItems(view, count, fn, collections)
 
     view.commit() 

_______________________________________________
Commits mailing list
Commits@osafoundation.org
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to