2020import debug # pyflakes:ignore
2121
2222import ietf .review .mailarch
23+
2324from ietf .doc .factories import ( NewRevisionDocEventFactory , IndividualDraftFactory , WgDraftFactory ,
24- WgRfcFactory , ReviewFactory , DocumentFactory )
25- from ietf .doc .models import DocumentAuthor , RelatedDocument , DocEvent , ReviewRequestDocEvent , ReviewAssignmentDocEvent
25+ WgRfcFactory , ReviewFactory , DocumentFactory )
26+ from ietf .doc .models import ( DocumentAuthor , RelatedDocument , DocEvent , ReviewRequestDocEvent ,
27+ ReviewAssignmentDocEvent , )
2628from ietf .group .factories import RoleFactory , ReviewTeamFactory
2729from ietf .group .models import Group
2830from ietf .message .models import Message
29- from ietf .name .models import ReviewResultName , ReviewRequestStateName , ReviewAssignmentStateName , \
30- ReviewTypeName
31+ from ietf .name .models import ReviewResultName , ReviewRequestStateName , ReviewAssignmentStateName , ReviewTypeName
32+ from ietf . person . factories import PersonFactory
3133from ietf .person .models import Email , Person
3234from ietf .review .factories import ReviewRequestFactory , ReviewAssignmentFactory
33- from ietf .review .models import (ReviewRequest , ReviewerSettings ,
34- ReviewWish , NextReviewerInTeam )
35+ from ietf .review .models import ReviewRequest , ReviewerSettings , ReviewWish , NextReviewerInTeam
3536from ietf .review .policies import get_reviewer_queue_policy
36-
37- from ietf .utils .test_utils import TestCase
37+ from ietf .utils .mail import outbox , empty_outbox , parseaddr , on_behalf_of , get_payload_text
3838from ietf .utils .test_utils import login_testing_unauthorized , reload_db_objects
39- from ietf .utils .mail import outbox , empty_outbox , parseaddr , on_behalf_of
40- from ietf .person .factories import PersonFactory
39+ from ietf .utils .test_utils import TestCase
4140
4241class ReviewTests (TestCase ):
4342 def setUp (self ):
@@ -228,7 +227,7 @@ def test_close_request(self):
228227 self .assertIn ('<reviewer@example.com>' , outbox [0 ]["To" ])
229228 self .assertNotIn ("<reviewsecretary@example.com>" , outbox [0 ]["To" ])
230229 self .assertIn ("reviewsecretary2@example.com" , outbox [0 ]["CC" ])
231- mail_content = outbox [0 ]. get_payload ( decode = True ). decode ( "utf-8" ). lower ( )
230+ mail_content = get_payload_text ( outbox [0 ])
232231 self .assertIn ("closed" , mail_content )
233232 self .assertIn ("review_request_close_comment" , mail_content )
234233
@@ -330,7 +329,7 @@ def test_assign_reviewer(self):
330329
331330 self .assertEqual (len (outbox ), 1 )
332331 self .assertEqual ('"Some Reviewer" <reviewer@example.com>' , outbox [0 ]["To" ])
333- message = outbox [0 ]. get_payload ( decode = True ). decode ( "utf-8" )
332+ message = get_payload_text ( outbox [0 ])
334333 self .assertIn ("Pages: {}" .format (doc .pages ), message )
335334 self .assertIn ("{} has assigned {}" .format (secretary .person .ascii , reviewer .person .ascii ), message )
336335 self .assertIn ("This team has completed other reviews" , message )
@@ -423,7 +422,7 @@ def test_reject_reviewer_assignment(self):
423422 self .assertEqual (len (outbox ), 1 )
424423 self .assertIn (assignment .reviewer .address , outbox [0 ]["To" ])
425424 self .assertNotIn ("<reviewsecretary@example.com>" , outbox [0 ]["To" ])
426- self .assertTrue ("Test message" in outbox [0 ]. get_payload ( decode = True ). decode ( "utf-8" ))
425+ self .assertTrue ("Test message" in get_payload_text ( outbox [0 ]))
427426
428427 # try again, but now with an expired review request, which should not be allowed (#2277)
429428 assignment .state_id = 'assigned'
@@ -645,7 +644,7 @@ def test_complete_review_upload_content(self):
645644 self .assertEqual (len (outbox ), 1 )
646645 self .assertIn (assignment .review_request .team .list_email , outbox [0 ]["To" ])
647646 self .assertIn (assignment .reviewer .role_set .filter (group = assignment .review_request .team ,name = 'reviewer' ).first ().person .plain_name (), parseaddr (outbox [0 ]["From" ])[0 ] )
648- self .assertIn ("This is a review" , outbox [0 ]. get_payload ( decode = True ). decode ( "utf-8" ))
647+ self .assertIn ("This is a review" , get_payload_text ( outbox [0 ]))
649648
650649 self .assertIn (settings .MAILING_LIST_ARCHIVE_URL , assignment .review .external_url )
651650
@@ -658,7 +657,7 @@ def test_complete_review_upload_content(self):
658657 self .assertEqual (parseaddr (outbox [0 ]["To" ]), parseaddr (message .to ))
659658 self .assertEqual (parseaddr (outbox [0 ]["From" ]), parseaddr (on_behalf_of (message .frm )))
660659 self .assertEqual (parseaddr (outbox [0 ]["Reply-To" ]), parseaddr (message .frm ))
661- self .assertEqual (outbox [ 0 ]. get_payload ( decode = True ). decode ( str ( outbox [0 ]. get_charset ()) ), message .body )
660+ self .assertEqual (get_payload_text ( outbox [0 ]), message .body )
662661
663662 # check the review document page
664663 url = urlreverse ('ietf.doc.views_doc.document_main' , kwargs = { "name" : assignment .review .name })
@@ -699,7 +698,7 @@ def test_complete_review_enter_content(self):
699698
700699 self .assertEqual (len (outbox ), 1 )
701700 self .assertIn (assignment .review_request .team .list_email , outbox [0 ]["To" ])
702- self .assertIn ("This is a review" , outbox [0 ]. get_payload ( decode = True ). decode ( "utf-8" ))
701+ self .assertIn ("This is a review" , get_payload_text ( outbox [0 ]))
703702
704703 self .assertIn (settings .MAILING_LIST_ARCHIVE_URL , assignment .review .external_url )
705704
@@ -740,7 +739,7 @@ def test_complete_review_enter_content_by_secretary(self):
740739
741740 self .assertEqual (len (outbox ), 1 )
742741 self .assertIn (assignment .review_request .team .list_email , outbox [0 ]["To" ])
743- self .assertIn ("This is a review" , outbox [0 ]. get_payload ( decode = True ). decode ( "utf-8" ))
742+ self .assertIn ("This is a review" , get_payload_text ( outbox [0 ]))
744743
745744 self .assertIn (settings .MAILING_LIST_ARCHIVE_URL , assignment .review .external_url )
746745
@@ -767,7 +766,7 @@ def test_complete_notify_ad_because_team_settings(self):
767766
768767 self .assertEqual (len (outbox ), 2 )
769768 self .assertIn ('Has Issues' , outbox [- 1 ]['Subject' ])
770- self .assertIn ('settings indicated' , outbox [- 1 ]. get_payload ( decode = True ). decode ( "utf-8" ))
769+ self .assertIn ('settings indicated' , get_payload_text ( outbox [- 1 ]))
771770
772771 def test_complete_notify_ad_because_checkbox (self ):
773772 assignment , url = self .setup_complete_review_test ()
@@ -791,7 +790,7 @@ def test_complete_notify_ad_because_checkbox(self):
791790
792791 self .assertEqual (len (outbox ), 2 )
793792 self .assertIn ('Has Issues' , outbox [- 1 ]['Subject' ])
794- self .assertIn ('reviewer indicated' , outbox [- 1 ]. get_payload ( decode = True ). decode ( "utf-8" ))
793+ self .assertIn ('reviewer indicated' , get_payload_text ( outbox [- 1 ]))
795794
796795 @patch ('requests.get' )
797796 def test_complete_review_link_to_mailing_list (self , mock ):
@@ -908,7 +907,7 @@ def test_partially_complete_review(self):
908907
909908 self .assertTrue (assignment .review_request .team .list_email in outbox [1 ]["To" ])
910909 self .assertTrue ("partial review" in outbox [1 ]["Subject" ].lower ())
911- body = outbox [1 ]. get_payload ( decode = True ). decode ( "utf-8" )
910+ body = get_payload_text ( outbox [1 ])
912911 self .assertTrue ("This is a review" in body )
913912 # This review has a line longer than 80, but less than 100; it should
914913 # not be wrapped.
@@ -941,7 +940,7 @@ def test_partially_complete_review(self):
941940
942941 # This review has a line longer than 100; it should be wrapped to less
943942 # than 80.
944- body = outbox [2 ]. get_payload ( decode = True ). decode ( "utf-8" )
943+ body = get_payload_text ( outbox [2 ])
945944 self .assertIn ('really, really, really' , body )
946945 self .assertTrue (all ( len (line ) <= 80 for line in body .splitlines () ))
947946
0 commit comments