@@ -108,8 +108,12 @@ def testAddMessageNoEscape(self):
108108class testCsvExport (object ):
109109
110110 def testCSVExportBase (self ):
111+ if 'SENDMAILDEBUG' not in os .environ :
112+ os .environ ['SENDMAILDEBUG' ] = 'mail-test1.log'
113+ SENDMAILDEBUG = os .environ ['SENDMAILDEBUG' ]
114+
111115 cl = self ._make_client (
112- {'@columns' : 'id,title,status,keyword,assignedto,nosy,creation' },
116+ {'@columns' : 'id,title,status,keyword,assignedto,nosy,creation,messages ' },
113117 nodeid = None , userid = '1' )
114118 cl .classname = 'issue'
115119
@@ -127,19 +131,26 @@ def dummyClosure(adate=None, translator=None):
127131 return dummyClosure
128132 date .Date = dummyDate ()
129133
134+ a_msg = self .db .msg .create (content = "23a" , author = "4" ,
135+ messageid = "xyzzy@there" ,
136+ recipients = ['3' ])
137+ b_msg = self .db .msg .create (content = "23b" , author = "3" ,
138+ messageid = "xyzzy@here" ,
139+ recipients = ['4' ])
140+
130141 self .db .issue .create (title = 'foo1' , status = '2' , assignedto = '4' , nosy = ['3' ,demo_id ])
131142 self .db .issue .create (title = 'bar2' , status = '1' , assignedto = '3' , keyword = [key_id1 ,key_id2 ])
132- self .db .issue .create (title = 'baz32' , status = '4' )
143+ self .db .issue .create (title = 'baz32' , status = '4' , messages = [a_msg , b_msg ])
144+
133145 output = io .BytesIO ()
134146 cl .request = MockNull ()
135147 cl .request .wfile = output
136148 # call export version that outputs names
137149 actions .ExportCSVAction (cl ).handle ()
138- should_be = (s2b ('"id","title","status","keyword","assignedto","nosy","creation"\r \n '
139- '"1","foo1","deferred","","Contrary, Mary","Bork, Chef;Contrary, Mary;demo","2000-06-26 00:34"\r \n '
140- '"2","bar2","unread","keyword1;keyword2","Bork, Chef","Bork, Chef","2000-06-26 00:34"\r \n '
141- '"3","baz32","need-eg","","","","2000-06-26 00:34"\r \n ' ))
142-
150+ should_be = (s2b ('"id","title","status","keyword","assignedto","nosy","creation","messages"\r \n '
151+ '"1","foo1","deferred","","Contrary, Mary","Bork, Chef;Contrary, Mary;demo","2000-06-26 00:34",""\r \n '
152+ '"2","bar2","unread","keyword1;keyword2","Bork, Chef","Bork, Chef","2000-06-26 00:34",""\r \n '
153+ '"3","baz32","need-eg","","","Bork, Chef;Contrary, Mary","2000-06-26 00:34","1;2"\r \n ' ))
143154
144155 #print(should_be)
145156 #print(output.getvalue())
@@ -149,10 +160,10 @@ def dummyClosure(adate=None, translator=None):
149160 cl .request .wfile = output
150161 # call export version that outputs id numbers
151162 actions .ExportCSVWithIdAction (cl ).handle ()
152- should_be = s2b ('"id","title","status","keyword","assignedto","nosy","creation"\r \n '
153- '''"1","foo1","2","[]","4","['3', '4', '5']","2000-06-26.00:34:02"\r \n '''
154- '''"2","bar2","1","['1', '2']","3","['3']","2000-06-26.00:34:02"\r \n '''
155- '''"3","baz32","4","[]","None","[]","2000-06-26.00:34:02"\r \n ''' )
163+ should_be = s2b ('"id","title","status","keyword","assignedto","nosy","creation","messages" \r \n '
164+ '''"1","foo1","2","[]","4","['3', '4', '5']","2000-06-26.00:34:02","[]" \r \n '''
165+ '''"2","bar2","1","['1', '2']","3","['3']","2000-06-26.00:34:02","[]" \r \n '''
166+ '''"3","baz32","4","[]","None","['3', '4' ]","2000-06-26.00:34:02","['1', '2'] "\r \n ''' )
156167 #print(should_be)
157168 #print(output.getvalue())
158169 self .assertEqual (output .getvalue (), should_be )
@@ -184,6 +195,11 @@ def dummyClosure(adate=None, translator=None):
184195 "\" 2\" ,\" bar2\" ,\" 1\" ,\" ['1', '2']\" ,\" 3\" ,\" ['3']\" \r \n " )
185196 self .assertEqual (output .getvalue (), should_be )
186197
198+ # clean up from email log
199+ if os .path .exists (SENDMAILDEBUG ):
200+ os .remove (SENDMAILDEBUG )
201+
202+
187203class FormTestCase (FormTestParent , StringFragmentCmpHelper , testCsvExport , unittest .TestCase ):
188204
189205 def setUp (self ):
0 commit comments