@@ -68,6 +68,8 @@ def setUp(self):
6868 nomcom_test_data ()
6969 self .cert_file , self .privatekey_file = get_cert_files ()
7070 self .year = NOMCOM_YEAR
71+ self .email_from = settings .NOMCOM_FROM_EMAIL .format (year = self .year )
72+ self .assertIn (self .year , self .email_from )
7173
7274 # private urls
7375 self .private_index_url = reverse ('ietf.nomcom.views.private_index' , kwargs = {'year' : self .year })
@@ -494,14 +496,17 @@ def test_public_nominate(self):
494496 self .assertEqual (len (outbox ), messages_before + 3 )
495497
496498 self .assertEqual ('IETF Nomination Information' , outbox [- 3 ]['Subject' ])
497- self .assertTrue ('nominee' in outbox [- 3 ]['To' ])
499+ self .assertEqual (self .email_from , outbox [- 3 ]['From' ])
500+ self .assertIn ('nominee' , outbox [- 3 ]['To' ])
498501
499502 self .assertEqual ('Nomination Information' , outbox [- 2 ]['Subject' ])
500- self .assertTrue ('nomcomchair' in outbox [- 2 ]['To' ])
503+ self .assertEqual (self .email_from , outbox [- 2 ]['From' ])
504+ self .assertIn ('nomcomchair' , outbox [- 2 ]['To' ])
501505
502506 self .assertEqual ('Nomination receipt' , outbox [- 1 ]['Subject' ])
503- self .assertTrue ('plain' in outbox [- 1 ]['To' ])
504- self .assertTrue (u'Comments with accents äöå' in unicode (outbox [- 1 ].get_payload (decode = True ),"utf-8" ,"replace" ))
507+ self .assertEqual (self .email_from , outbox [- 1 ]['From' ])
508+ self .assertIn ('plain' , outbox [- 1 ]['To' ])
509+ self .assertIn (u'Comments with accents äöå' , unicode (outbox [- 1 ].get_payload (decode = True ),"utf-8" ,"replace" ))
505510
506511 # Nominate the same person for the same position again without asking for confirmation
507512
@@ -510,7 +515,8 @@ def test_public_nominate(self):
510515 self .nominate_view (public = True )
511516 self .assertEqual (len (outbox ), messages_before + 1 )
512517 self .assertEqual ('Nomination Information' , outbox [- 1 ]['Subject' ])
513- self .assertTrue ('nomcomchair' in outbox [- 1 ]['To' ])
518+ self .assertEqual (self .email_from , outbox [- 1 ]['From' ])
519+ self .assertIn ('nomcomchair' , outbox [- 1 ]['To' ])
514520
515521 def test_private_nominate (self ):
516522 self .access_member_url (self .private_nominate_url )
@@ -527,17 +533,21 @@ def test_public_nominate_newperson(self):
527533 self .assertEqual (len (outbox ), messages_before + 4 )
528534
529535 self .assertEqual ('New person is created' , outbox [- 4 ]['Subject' ])
530- self .assertTrue ('secretariat' in outbox [- 4 ]['To' ])
536+ self .assertEqual (self .email_from , outbox [- 4 ]['From' ])
537+ self .assertIn ('secretariat' , outbox [- 4 ]['To' ])
531538
532539 self .assertEqual ('IETF Nomination Information' , outbox [- 3 ]['Subject' ])
533- self .assertTrue ('nominee' in outbox [- 3 ]['To' ])
540+ self .assertEqual (self .email_from , outbox [- 3 ]['From' ])
541+ self .assertIn ('nominee' , outbox [- 3 ]['To' ])
534542
535543 self .assertEqual ('Nomination Information' , outbox [- 2 ]['Subject' ])
536- self .assertTrue ('nomcomchair' in outbox [- 2 ]['To' ])
544+ self .assertEqual (self .email_from , outbox [- 2 ]['From' ])
545+ self .assertIn ('nomcomchair' , outbox [- 2 ]['To' ])
537546
538547 self .assertEqual ('Nomination receipt' , outbox [- 1 ]['Subject' ])
539- self .assertTrue ('plain' in outbox [- 1 ]['To' ])
540- self .assertTrue (u'Comments with accents äöå' in unicode (outbox [- 1 ].get_payload (decode = True ),"utf-8" ,"replace" ))
548+ self .assertEqual (self .email_from , outbox [- 1 ]['From' ])
549+ self .assertIn ('plain' , outbox [- 1 ]['To' ])
550+ self .assertIn (u'Comments with accents äöå' , unicode (outbox [- 1 ].get_payload (decode = True ),"utf-8" ,"replace" ))
541551
542552 # Nominate the same person for the same position again without asking for confirmation
543553
@@ -546,7 +556,8 @@ def test_public_nominate_newperson(self):
546556 self .nominate_view (public = True )
547557 self .assertEqual (len (outbox ), messages_before + 1 )
548558 self .assertEqual ('Nomination Information' , outbox [- 1 ]['Subject' ])
549- self .assertTrue ('nomcomchair' in outbox [- 1 ]['To' ])
559+ self .assertEqual (self .email_from , outbox [- 1 ]['From' ])
560+ self .assertIn ('nomcomchair' , outbox [- 1 ]['To' ])
550561
551562 def test_private_nominate_newperson (self ):
552563 self .access_member_url (self .private_nominate_url )
@@ -562,8 +573,9 @@ def test_public_nominate_with_automatic_questionnaire(self):
562573 self .nominate_view (public = True )
563574 self .assertEqual (len (outbox ), 3 )
564575 # test_public_nominate checks the other messages
565- self .assertTrue ('Questionnaire' in outbox [1 ]['Subject' ])
566- self .assertTrue ('nominee@' in outbox [1 ]['To' ])
576+ self .assertEqual (self .email_from , outbox [- 1 ]['From' ])
577+ self .assertIn ('Questionnaire' , outbox [1 ]['Subject' ])
578+ self .assertIn ('nominee@' , outbox [1 ]['To' ])
567579
568580
569581 def nominate_view (self , * args , ** kwargs ):
@@ -775,13 +787,14 @@ def test_public_feedback(self):
775787 # We're interested in the confirmation receipt here
776788 self .assertEqual (len (outbox ),3 )
777789 self .assertEqual ('NomCom comment confirmation' , outbox [2 ]['Subject' ])
778- self .assertTrue ('plain' in outbox [2 ]['To' ])
779- self .assertTrue (u'Comments with accents äöå' in unicode (outbox [2 ].get_payload (decode = True ),"utf-8" ,"replace" ))
790+ self .assertEqual (self .email_from , outbox [- 2 ]['From' ])
791+ self .assertIn ('plain' , outbox [2 ]['To' ])
792+ self .assertIn (u'Comments with accents äöå' , unicode (outbox [2 ].get_payload (decode = True ),"utf-8" ,"replace" ))
780793
781794 empty_outbox ()
782795 self .feedback_view (public = True )
783796 self .assertEqual (len (outbox ),1 )
784- self .assertFalse ('confirmation' in outbox [0 ]['Subject' ])
797+ self .assertNotIn ('confirmation' , outbox [0 ]['Subject' ])
785798
786799 def test_private_feedback (self ):
787800 self .access_member_url (self .private_feedback_url )
@@ -1007,17 +1020,17 @@ def test_command(self):
10071020 self .nomcom .save ()
10081021 c .handle (None ,None )
10091022 self .assertEqual (len (outbox ), messages_before + 2 )
1010- self .assertTrue ('nominee1@example.org' in outbox [- 1 ]['To' ])
1011- self .assertTrue ('please complete' in outbox [- 1 ]['Subject' ])
1012- self .assertTrue ('nominee1@example.org' in outbox [- 2 ]['To' ])
1013- self .assertTrue ('please accept' in outbox [- 2 ]['Subject' ])
1023+ self .assertIn ('nominee1@example.org' , outbox [- 1 ]['To' ])
1024+ self .assertIn ('please complete' , outbox [- 1 ]['Subject' ])
1025+ self .assertIn ('nominee1@example.org' , outbox [- 2 ]['To' ])
1026+ self .assertIn ('please accept' , outbox [- 2 ]['Subject' ])
10141027 messages_before = len (outbox )
10151028 self .nomcom .reminder_interval = 4
10161029 self .nomcom .save ()
10171030 c .handle (None ,None )
10181031 self .assertEqual (len (outbox ), messages_before + 1 )
1019- self .assertTrue ('nominee2@example.org' in outbox [- 1 ]['To' ])
1020- self .assertTrue ('please accept' in outbox [- 1 ]['Subject' ])
1032+ self .assertIn ('nominee2@example.org' , outbox [- 1 ]['To' ])
1033+ self .assertIn ('please accept' , outbox [- 1 ]['Subject' ])
10211034
10221035 def test_remind_accept_view (self ):
10231036 url = reverse ('ietf.nomcom.views.send_reminder_mail' , kwargs = {'year' : NOMCOM_YEAR ,'type' :'accept' })
@@ -1027,8 +1040,8 @@ def test_remind_accept_view(self):
10271040 response = self .client .post (url , test_data )
10281041 self .assertEqual (response .status_code , 200 )
10291042 self .assertEqual (len (outbox ), messages_before + 2 )
1030- self .assertTrue ('nominee1@' in outbox [- 2 ]['To' ])
1031- self .assertTrue ('nominee2@' in outbox [- 1 ]['To' ])
1043+ self .assertIn ('nominee1@' , outbox [- 2 ]['To' ])
1044+ self .assertIn ('nominee2@' , outbox [- 1 ]['To' ])
10321045
10331046 def test_remind_questionnaire_view (self ):
10341047 url = reverse ('ietf.nomcom.views.send_reminder_mail' , kwargs = {'year' : NOMCOM_YEAR ,'type' :'questionnaire' })
@@ -1038,7 +1051,7 @@ def test_remind_questionnaire_view(self):
10381051 response = self .client .post (url , test_data )
10391052 self .assertEqual (response .status_code , 200 )
10401053 self .assertEqual (len (outbox ), messages_before + 1 )
1041- self .assertTrue ('nominee1@' in outbox [- 1 ]['To' ])
1054+ self .assertIn ('nominee1@' , outbox [- 1 ]['To' ])
10421055
10431056class InactiveNomcomTests (TestCase ):
10441057
@@ -1060,8 +1073,8 @@ def test_feedback_closed(self):
10601073 response = self .client .get (url )
10611074 self .assertEqual (response .status_code , 200 )
10621075 q = PyQuery (response .content )
1063- self .assertTrue ( '(Concluded)' in q ('h1' ).text ())
1064- self .assertTrue ( 'closed' in q ('#instructions' ).text ())
1076+ self .assertIn ( '(Concluded)' , q ('h1' ).text ())
1077+ self .assertIn ( 'closed' , q ('#instructions' ).text ())
10651078 self .assertTrue ( q ('#nominees a' ) )
10661079 self .assertFalse ( q ('#nominees a[href]' ) )
10671080
@@ -1079,7 +1092,7 @@ def test_feedback_closed(self):
10791092 response = self .client .post (url , test_data )
10801093 self .assertEqual (response .status_code , 200 )
10811094 q = PyQuery (response .content )
1082- self .assertTrue ( 'closed' in q ('#instructions' ).text ())
1095+ self .assertIn ( 'closed' , q ('#instructions' ).text ())
10831096 self .assertEqual ( len (outbox ), 0 )
10841097 self .assertEqual ( fb_before , self .nc .feedback_set .count () )
10851098
@@ -1091,8 +1104,8 @@ def test_nominations_closed(self):
10911104 response = self .client .get (url )
10921105 self .assertEqual (response .status_code , 200 )
10931106 q = PyQuery (response .content )
1094- self .assertTrue ( '(Concluded)' in q ('h1' ).text ())
1095- self .assertTrue ( 'closed' in q ('.alert-warning' ).text ())
1107+ self .assertIn ( '(Concluded)' , q ('h1' ).text ())
1108+ self .assertIn ( 'closed' , q ('.alert-warning' ).text ())
10961109
10971110 def test_acceptance_closed (self ):
10981111 today = datetime .date .today ().strftime ('%Y%m%d' )
@@ -1136,7 +1149,7 @@ def test_cannot_modify_nominees(self):
11361149 response = self .client .post (url , test_data )
11371150 self .assertEqual (response .status_code , 200 )
11381151 q = PyQuery (response .content )
1139- self .assertTrue ('not active' in q ('.alert-warning' ).text () )
1152+ self .assertIn ('not active' , q ('.alert-warning' ).text () )
11401153
11411154 def test_email_pasting_closed (self ):
11421155 url = reverse ('ietf.nomcom.views.private_feedback_email' , kwargs = {'year' :self .nc .year ()})
@@ -1150,7 +1163,7 @@ def test_email_pasting_closed(self):
11501163 response = self .client .post (url , test_data )
11511164 self .assertEqual (response .status_code , 200 )
11521165 q = PyQuery (response .content )
1153- self .assertTrue ('not active' in q ('.alert-warning' ).text () )
1166+ self .assertIn ('not active' , q ('.alert-warning' ).text () )
11541167
11551168 def test_questionnaire_entry_closed (self ):
11561169 url = reverse ('ietf.nomcom.views.private_questionnaire' , kwargs = {'year' :self .nc .year ()})
@@ -1162,7 +1175,7 @@ def test_questionnaire_entry_closed(self):
11621175 response = self .client .post (url , {})
11631176 self .assertEqual (response .status_code , 200 )
11641177 q = PyQuery (response .content )
1165- self .assertTrue ('not active' in q ('.alert-warning' ).text () )
1178+ self .assertIn ('not active' , q ('.alert-warning' ).text () )
11661179
11671180 def _test_send_reminders_closed (self ,rtype ):
11681181 url = reverse ('ietf.nomcom.views.send_reminder_mail' , kwargs = {'year' :self .nc .year (),'type' :rtype })
@@ -1174,7 +1187,7 @@ def _test_send_reminders_closed(self,rtype):
11741187 response = self .client .post (url , {})
11751188 self .assertEqual (response .status_code , 200 )
11761189 q = PyQuery (response .content )
1177- self .assertTrue ('not active' in q ('.alert-warning' ).text () )
1190+ self .assertIn ('not active' , q ('.alert-warning' ).text () )
11781191
11791192 def test_send_accept_reminders_closed (self ):
11801193 self ._test_send_reminders_closed ('accept' )
@@ -1191,7 +1204,7 @@ def test_merge_closed(self):
11911204 response = self .client .post (url , {})
11921205 self .assertEqual (response .status_code , 200 )
11931206 q = PyQuery (response .content )
1194- self .assertTrue ('not active' in q ('.alert-warning' ).text () )
1207+ self .assertIn ('not active' , q ('.alert-warning' ).text () )
11951208
11961209 def test_cannot_edit_position (self ):
11971210 url = reverse ('ietf.nomcom.views.edit_position' ,kwargs = {'year' :self .nc .year (),'position_id' :self .nc .position_set .first ().id })
@@ -1370,7 +1383,7 @@ def test_accept_reject_nomination_edges(self):
13701383 url = reverse ('ietf.nomcom.views.process_nomination_status' , kwargs = kwargs )
13711384 response = self .client .get (url )
13721385 self .assertEqual (response .status_code ,403 )
1373- self .assertTrue ('already was' in unicontent (response ))
1386+ self .assertIn ('already was' , unicontent (response ))
13741387
13751388 settings .DAYS_TO_EXPIRE_NOMINATION_LINK = 2
13761389 np .time = np .time - datetime .timedelta (days = 3 )
@@ -1380,13 +1393,13 @@ def test_accept_reject_nomination_edges(self):
13801393 url = reverse ('ietf.nomcom.views.process_nomination_status' , kwargs = kwargs )
13811394 response = self .client .get (url )
13821395 self .assertEqual (response .status_code ,403 )
1383- self .assertTrue ('Link expired' in unicontent (response ))
1396+ self .assertIn ('Link expired' , unicontent (response ))
13841397
13851398 kwargs ['hash' ] = 'bad'
13861399 url = reverse ('ietf.nomcom.views.process_nomination_status' , kwargs = kwargs )
13871400 response = self .client .get (url )
13881401 self .assertEqual (response .status_code ,403 )
1389- self .assertTrue ('Bad hash!' in unicontent (response ))
1402+ self .assertIn ('Bad hash!' , unicontent (response ))
13901403
13911404 def test_accept_reject_nomination_comment (self ):
13921405 np = self .nc .nominee_set .order_by ('pk' ).first ().nomineeposition_set .order_by ('pk' ).first ()
@@ -1728,7 +1741,7 @@ def test_request_merge(self):
17281741 response = self .client .post (url ,{'primary_person' :nominee1 .person .pk ,
17291742 'duplicate_persons' :[nominee1 .person .pk ]})
17301743 self .assertEqual (response .status_code , 200 )
1731- self .assertTrue ('must not also be listed as a duplicate' in unicontent (response ))
1744+ self .assertIn ('must not also be listed as a duplicate' , unicontent (response ))
17321745 response = self .client .post (url ,{'primary_person' :nominee1 .person .pk ,
17331746 'duplicate_persons' :[nominee2 .person .pk ]})
17341747 self .assertEqual (response .status_code , 302 )
@@ -1843,7 +1856,7 @@ def test_public_accepting_feedback(self):
18431856
18441857 posurl = url + "?nominee=%d&position=%d" % (pos .nominee_set .first ().pk , pos .pk )
18451858 response = self .client .get (posurl )
1846- self .assertTrue ('not currently accepting feedback' in unicontent (response ))
1859+ self .assertIn ('not currently accepting feedback' , unicontent (response ))
18471860
18481861 test_data = {'comments' : 'junk' ,
18491862 'position_name' : pos .name ,
@@ -1854,17 +1867,17 @@ def test_public_accepting_feedback(self):
18541867 'nominator_name' : self .plain_person .plain_name (),
18551868 }
18561869 response = self .client .post (posurl , test_data )
1857- self .assertTrue ('not currently accepting feedback' in unicontent (response ))
1870+ self .assertIn ('not currently accepting feedback' , unicontent (response ))
18581871
18591872 topicurl = url + "?topic=%d" % (topic .pk , )
18601873 response = self .client .get (topicurl )
1861- self .assertTrue ('not currently accepting feedback' in unicontent (response ))
1874+ self .assertIn ('not currently accepting feedback' , unicontent (response ))
18621875
18631876 test_data = {'comments' : 'junk' ,
18641877 'confirmation' : False ,
18651878 }
18661879 response = self .client .post (topicurl , test_data )
1867- self .assertTrue ('not currently accepting feedback' in unicontent (response ))
1880+ self .assertIn ('not currently accepting feedback' , unicontent (response ))
18681881
18691882 def test_private_accepting_feedback (self ):
18701883 url = reverse ('ietf.nomcom.views.private_feedback' ,kwargs = {'year' :self .nc .year ()})
@@ -1943,14 +1956,14 @@ def testAddEditListRemoveTopic(self):
19431956 login_testing_unauthorized (self ,self .chair .user .username ,url )
19441957 response = self .client .get (url )
19451958 self .assertEqual (response .status_code ,200 )
1946- self .assertTrue ('Test Topic Modified' in unicontent (response ))
1959+ self .assertIn ('Test Topic Modified' , unicontent (response ))
19471960
19481961 self .client .logout ()
19491962 url = reverse ('ietf.nomcom.views.remove_topic' , kwargs = {'year' :self .nc .year (),'topic_id' :self .nc .topic_set .first ().pk })
19501963 login_testing_unauthorized (self ,self .chair .user .username ,url )
19511964 response = self .client .get (url )
19521965 self .assertEqual (response .status_code ,200 )
1953- self .assertTrue ('Test Topic Modified' in unicontent (response ))
1966+ self .assertIn ('Test Topic Modified' , unicontent (response ))
19541967 response = self .client .post (url ,{'remove' :1 })
19551968 self .assertEqual (response .status_code ,302 )
19561969 self .assertFalse (self .nc .topic_set .exists ())
@@ -1969,7 +1982,7 @@ def testClassifyTopicFeedback(self):
19691982 'form-0-id' : feedback .id ,
19701983 'form-0-type' : 'comment' ,
19711984 })
1972- self .assertTrue ('You must choose at least one Nominee or Topic' in unicontent (response ))
1985+ self .assertIn ('You must choose at least one Nominee or Topic' , unicontent (response ))
19731986 response = self .client .post (url , {'form-TOTAL_FORMS' :1 ,
19741987 'form-INITIAL_FORMS' :1 ,
19751988 'end' :'Save feedback' ,
@@ -2000,7 +2013,7 @@ def testAudience(self):
20002013 login_testing_unauthorized (self , self .plain_person .user .username , feedback_url )
20012014 r = self .client .get (feedback_url )
20022015 self .assertEqual (r .status_code ,200 )
2003- self .assertFalse (topic .subject in unicontent (r ))
2016+ self .assertNotIn (topic .subject , unicontent (r ))
20042017 topic_url = feedback_url + '?topic=%d' % topic .pk
20052018 r = self .client .get (topic_url )
20062019 self .assertEqual (r .status_code ,404 )
@@ -2015,7 +2028,7 @@ def testAudience(self):
20152028 self .client .login (username = valid_user .user .username ,password = valid_user .user .username + "+password" )
20162029 r = self .client .get (feedback_url )
20172030 self .assertEqual (r .status_code ,200 )
2018- self .assertTrue (topic .subject in unicontent (r ))
2031+ self .assertIn (topic .subject , unicontent (r ))
20192032 r = self .client .get (topic_url )
20202033 self .assertEqual (r .status_code ,200 )
20212034 r = self .client .post (topic_url , {'comments' :'junk' , 'confirmation' :False })
0 commit comments