@@ -80,73 +80,181 @@ def test_private_index_view(self):
8080 def test_private_merge_view (self ):
8181 """Verify private merge view"""
8282
83+ nominees = [u'nominee0@example.com' ,
84+ u'nominee1@example.com' ,
85+ u'nominee2@example.com' ,
86+ u'nominee3@example.com' ]
87+
8388 # do nominations
8489 login_testing_unauthorized (self , COMMUNITY_USER , self .public_nominate_url )
85- self .nominate_view (public = True , nominee_email = u'nominee@example.com' ,
90+ self .nominate_view (public = True ,
91+ nominee_email = nominees [0 ],
92+ position = 'IAOC' )
93+ self .nominate_view (public = True ,
94+ nominee_email = nominees [0 ],
8695 position = 'IAOC' )
87- self .nominate_view (public = True , nominee_email = u'nominee2@example.com' ,
96+ self .nominate_view (public = True ,
97+ nominee_email = nominees [1 ],
8898 position = 'IAOC' )
89- self .nominate_view (public = True , nominee_email = u'nominee3@example.com' ,
99+ self .nominate_view (public = True ,
100+ nominee_email = nominees [1 ],
101+ position = 'IAOC' )
102+ self .nominate_view (public = True ,
103+ nominee_email = nominees [2 ],
104+ position = 'IAB' )
105+ self .nominate_view (public = True ,
106+ nominee_email = nominees [2 ],
90107 position = 'IAB' )
91- self .nominate_view (public = True , nominee_email = u'nominee4@example.com' ,
108+ self .nominate_view (public = True ,
109+ nominee_email = nominees [3 ],
92110 position = 'TSV' )
111+ self .nominate_view (public = True ,
112+ nominee_email = nominees [3 ],
113+ position = 'TSV' )
114+ # Check nominee positions
115+ self .assertEqual (NomineePosition .objects .count (), 4 )
116+ self .assertEqual (Feedback .objects .nominations ().count (), 8 )
117+
118+ # Accept and declined nominations
119+ nominee_position = NomineePosition .objects .get (position__name = 'TSV' ,
120+ nominee__email__address = nominees [3 ])
121+ nominee_position .state = NomineePositionState .objects .get (slug = 'accepted' )
122+ nominee_position .save ()
123+
124+ nominee_position = NomineePosition .objects .get (position__name = 'IAOC' ,
125+ nominee__email__address = nominees [0 ])
126+ nominee_position .state = NomineePositionState .objects .get (slug = 'accepted' )
127+ nominee_position .save ()
128+
129+ nominee_position = NomineePosition .objects .get (position__name = 'IAOC' ,
130+ nominee__email__address = nominees [1 ])
131+ nominee_position .state = NomineePositionState .objects .get (slug = 'declined' )
132+ nominee_position .save ()
133+
134+ self .client .logout ()
135+
136+ # fill questionnaires (internally the function does new nominations)
137+ self .access_chair_url (self .add_questionnaire_url )
138+
139+ self .add_questionnaire (public = False ,
140+ nominee_email = nominees [0 ],
141+ position = 'IAOC' )
142+ self .add_questionnaire (public = False ,
143+ nominee_email = nominees [1 ],
144+ position = 'IAOC' )
145+ self .add_questionnaire (public = False ,
146+ nominee_email = nominees [2 ],
147+ position = 'IAB' )
148+ self .add_questionnaire (public = False ,
149+ nominee_email = nominees [3 ],
150+ position = 'TSV' )
151+ self .assertEqual (Feedback .objects .questionnaires ().count (), 4 )
93152
94153 self .client .logout ()
95154
96- # merge nominations
155+ ## Add feedbacks (internally the function does new nominations)
156+ self .access_member_url (self .private_feedback_url )
157+
158+ self .feedback_view (public = False ,
159+ nominee_email = nominees [0 ],
160+ position = 'IAOC' )
161+ self .feedback_view (public = False ,
162+ nominee_email = nominees [1 ],
163+ position = 'IAOC' )
164+ self .feedback_view (public = False ,
165+ nominee_email = nominees [2 ],
166+ position = 'IAB' )
167+ self .feedback_view (public = False ,
168+ nominee_email = nominees [03 ],
169+ position = 'TSV' )
170+
171+ self .assertEqual (Feedback .objects .comments ().count (), 4 )
172+ self .assertEqual (Feedback .objects .nominations ().count (), 16 )
173+ for nominee in nominees :
174+ self .assertEqual (Feedback .objects .nominations ().filter (nominee__email__address = nominee ).count (),
175+ 4 )
176+ self .assertEqual (Feedback .objects .comments ().filter (nominee__email__address = nominee ).count (),
177+ 1 )
178+ self .assertEqual (Feedback .objects .questionnaires ().filter (nominee__email__address = nominee ).count (),
179+ 1 )
180+
181+ self .client .logout ()
182+
183+ ## merge nominations
97184 self .access_chair_url (self .private_merge_url )
98185
99- test_data = {"secondary_emails" : "nominee@example.com, nominee2@example.com" ,
100- "primary_email" : "nominee@example.com" }
186+ test_data = {"secondary_emails" : "%s, %s" % ( nominees [ 0 ], nominees [ 1 ]) ,
187+ "primary_email" : nominees [ 0 ] }
101188 response = self .client .post (self .private_merge_url , test_data )
102189 self .assertEqual (response .status_code , 200 )
103190 self .assertContains (response , "info-message-error" )
104191
105- test_data = {"primary_email" : "nominee@example.com" ,
192+ test_data = {"primary_email" : nominees [ 0 ] ,
106193 "secondary_emails" : "" }
107194 response = self .client .post (self .private_merge_url , test_data )
108195 self .assertEqual (response .status_code , 200 )
109196 self .assertContains (response , "info-message-error" )
110197
111198 test_data = {"primary_email" : "" ,
112- "secondary_emails" : "nominee@example.com" }
199+ "secondary_emails" : nominees [ 0 ] }
113200 response = self .client .post (self .private_merge_url , test_data )
114201 self .assertEqual (response .status_code , 200 )
115202 self .assertContains (response , "info-message-error" )
116203
117204 test_data = {"primary_email" : "unknown@example.com" ,
118- "secondary_emails" : "nominee@example.com" }
205+ "secondary_emails" : nominees [ 0 ] }
119206 response = self .client .post (self .private_merge_url , test_data )
120207 self .assertEqual (response .status_code , 200 )
121208 self .assertContains (response , "info-message-error" )
122209
123- test_data = {"primary_email" : "nominee@example.com" ,
210+ test_data = {"primary_email" : nominees [ 0 ] ,
124211 "secondary_emails" : "unknown@example.com" }
125212 response = self .client .post (self .private_merge_url , test_data )
126213 self .assertEqual (response .status_code , 200 )
127214 self .assertContains (response , "info-message-error" )
128215
129- test_data = {"secondary_emails" : """nominee2@example.com ,
130- nominee3@example.com ,
131- nominee4@example.com """ ,
132- "primary_email" : "nominee@example.com" }
216+ test_data = {"secondary_emails" : """%s ,
217+ %s ,
218+ %s """ % ( nominees [ 1 ], nominees [ 2 ], nominees [ 3 ]) ,
219+ "primary_email" : nominees [ 0 ] }
133220
134221 response = self .client .post (self .private_merge_url , test_data )
135222 self .assertEqual (response .status_code , 200 )
136223 self .assertContains (response , "info-message-success" )
137224
138- self .assertEqual (Nominee .objects .filter (email__address = 'nominee2@example.com' ,
225+ self .assertEqual (Nominee .objects .filter (email__address = nominees [ 1 ] ,
139226 duplicated__isnull = False ).count (), 1 )
140- self .assertEqual (Nominee .objects .filter (email__address = 'nominee3@example.com' ,
227+ self .assertEqual (Nominee .objects .filter (email__address = nominees [ 2 ] ,
141228 duplicated__isnull = False ).count (), 1 )
142- self .assertEqual (Nominee .objects .filter (email__address = 'nominee4@example.com' ,
229+ self .assertEqual (Nominee .objects .filter (email__address = nominees [ 3 ] ,
143230 duplicated__isnull = False ).count (), 1 )
144231
145- nominee = Nominee .objects .get (email__address = 'nominee@example.com' )
146- self .assertEqual (Nomination .objects .filter (nominee = nominee ).count (), 4 )
147- self .assertEqual (Feedback .objects .filter (nominee = nominee ).count (), 4 )
232+ nominee = Nominee .objects .get (email__address = nominees [0 ])
233+
234+ self .assertEqual (Nomination .objects .filter (nominee = nominee ).count (), 16 )
235+ self .assertEqual (Feedback .objects .nominations ().filter (nominee = nominee ).count (),
236+ 16 )
237+ self .assertEqual (Feedback .objects .comments ().filter (nominee = nominee ).count (),
238+ 4 )
239+ self .assertEqual (Feedback .objects .questionnaires ().filter (nominee = nominee ).count (),
240+ 4 )
241+
242+ for nominee_email in nominees [1 :]:
243+ self .assertEqual (Feedback .objects .nominations ().filter (nominee__email__address = nominee_email ).count (),
244+ 0 )
245+ self .assertEqual (Feedback .objects .comments ().filter (nominee__email__address = nominee_email ).count (),
246+ 0 )
247+ self .assertEqual (Feedback .objects .questionnaires ().filter (nominee__email__address = nominee_email ).count (),
248+ 0 )
249+
148250 self .assertEqual (NomineePosition .objects .filter (nominee = nominee ).count (), 3 )
149251
252+ # Check nominations state
253+ self .assertEqual (NomineePosition .objects .get (position__name = 'TSV' ,
254+ nominee = nominee ).state .slug , u'accepted' )
255+ self .assertEqual (NomineePosition .objects .get (position__name = 'IAOC' ,
256+ nominee = nominee ).state .slug , u'declined' )
257+
150258 self .client .logout ()
151259
152260 def change_members (self , members ):
@@ -305,9 +413,9 @@ def nominate_view(self, *args, **kwargs):
305413 Person .objects .get (name = candidate_name , address = candidate_email )
306414 nominee = Nominee .objects .get (email = email )
307415 NomineePosition .objects .get (position = position , nominee = nominee )
308- feedback = Feedback .objects .get (positions__in = [position ],
309- nominee = nominee ,
310- type = FeedbackType .objects .get (slug = 'nomina' ))
416+ feedback = Feedback .objects .filter (positions__in = [position ],
417+ nominee = nominee ,
418+ type = FeedbackType .objects .get (slug = 'nomina' )). latest ( 'id' )
311419 if public :
312420 self .assertEqual (feedback .author , nominator_email )
313421
@@ -369,9 +477,9 @@ def add_questionnaire(self, *args, **kwargs):
369477 self .assertContains (response , "info-message-success" )
370478
371479 ## check objects
372- feedback = Feedback .objects .get (positions__in = [position ],
373- nominee = nominee ,
374- type = FeedbackType .objects .get (slug = 'questio' ))
480+ feedback = Feedback .objects .filter (positions__in = [position ],
481+ nominee = nominee ,
482+ type = FeedbackType .objects .get (slug = 'questio' )). latest ( 'id' )
375483
376484 ## to check feedback comments are saved like enrypted data
377485 self .assertNotEqual (feedback .comments , comments )
@@ -440,9 +548,9 @@ def feedback_view(self, *args, **kwargs):
440548 self .assertContains (response , "info-message-success" )
441549
442550 ## check objects
443- feedback = Feedback .objects .get (positions__in = [position ],
444- nominee = nominee ,
445- type = FeedbackType .objects .get (slug = 'comment' ))
551+ feedback = Feedback .objects .filter (positions__in = [position ],
552+ nominee = nominee ,
553+ type = FeedbackType .objects .get (slug = 'comment' )). latest ( 'id' )
446554 if public :
447555 self .assertEqual (feedback .author , nominator_email )
448556
0 commit comments