@@ -42,6 +42,7 @@ def setUp(self):
4242 self .edit_chair_url = reverse ('nomcom_edit_chair' , kwargs = {'year' : self .year })
4343 self .edit_nomcom_url = reverse ('nomcom_edit_nomcom' , kwargs = {'year' : self .year })
4444 self .private_nominate_url = reverse ('nomcom_private_nominate' , kwargs = {'year' : self .year })
45+ self .add_questionnaire_url = reverse ('nomcom_private_questionnaire' , kwargs = {'year' : self .year })
4546 self .private_feedback_url = reverse ('nomcom_private_feedback' , kwargs = {'year' : self .year })
4647
4748 # public urls
@@ -207,9 +208,8 @@ def test_edit_chair_view(self):
207208
208209 def test_edit_nomcom_view (self ):
209210 """Verify edit nomcom view"""
210- login_testing_unauthorized (self , COMMUNITY_USER , self .edit_nomcom_url )
211- login_testing_unauthorized (self , CHAIR_USER , self .edit_nomcom_url )
212- self .check_url_status (self .edit_nomcom_url , 200 )
211+ self .access_chair_url (self .edit_nomcom_url )
212+
213213 f = open (self .cert_file .name )
214214 response = self .client .post (self .edit_nomcom_url , {'public_key' : f })
215215 f .close ()
@@ -247,153 +247,209 @@ def test_questionnaires_view(self):
247247 """Verify questionnaires view"""
248248 self .check_url_status (self .questionnaires_url , 200 )
249249
250- def test_public_feedback (self ):
251- login_testing_unauthorized (self , COMMUNITY_USER , self .public_feedback_url )
252- return self .feedback_view (public = True )
250+ def test_public_nominate (self ):
251+ login_testing_unauthorized (self , COMMUNITY_USER , self .public_nominate_url )
252+ return self .nominate_view (public = True )
253253 self .client .logout ()
254254
255- def test_private_feedback (self ):
256- self .access_member_url (self .private_feedback_url )
257- return self .feedback_view (public = False )
255+ def test_private_nominate (self ):
256+ self .access_member_url (self .private_nominate_url )
257+ return self .nominate_view (public = False )
258258 self .client .logout ()
259259
260- def feedback_view (self , * args , ** kwargs ):
260+ def nominate_view (self , * args , ** kwargs ):
261261 public = kwargs .pop ('public' , True )
262262 nominee_email = kwargs .pop ('nominee_email' , u'nominee@example.com' )
263263 nominator_email = kwargs .pop ('nominator_email' , "%s%s" % (COMMUNITY_USER , EMAIL_DOMAIN ))
264264 position_name = kwargs .pop ('position' , 'IAOC' )
265265
266+ if public :
267+ nominate_url = self .public_nominate_url
268+ else :
269+ nominate_url = self .private_nominate_url
270+ response = self .client .get (nominate_url )
271+ self .assertEqual (response .status_code , 200 )
272+
273+ nomcom = get_nomcom_by_year (self .year )
274+ if not nomcom .public_key :
275+ self .assertNotContains (response , "nominateform" )
276+
277+ # save the cert file in tmp
278+ nomcom .public_key .storage .location = tempfile .gettempdir ()
279+ nomcom .public_key .save ('cert' , File (open (self .cert_file .name , 'r' )))
280+
281+ response = self .client .get (nominate_url )
282+ self .assertEqual (response .status_code , 200 )
283+ self .assertContains (response , "nominateform" )
284+
285+ position = Position .objects .get (name = position_name )
286+ candidate_email = nominee_email
287+ candidate_name = u'nominee'
288+ comments = 'test nominate view'
289+ candidate_phone = u'123456'
290+
291+ test_data = {'candidate_name' : candidate_name ,
292+ 'candidate_email' : candidate_email ,
293+ 'candidate_phone' : candidate_phone ,
294+ 'position' : position .id ,
295+ 'comments' : comments }
296+ if not public :
297+ test_data ['nominator_email' ] = nominator_email
298+
299+ response = self .client .post (nominate_url , test_data )
300+ self .assertEqual (response .status_code , 200 )
301+ self .assertContains (response , "info-message-success" )
302+
303+ # check objects
304+ email = Email .objects .get (address = candidate_email )
305+ Person .objects .get (name = candidate_name , address = candidate_email )
306+ nominee = Nominee .objects .get (email = email )
307+ 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' ))
311+ if public :
312+ self .assertEqual (feedback .author , nominator_email )
313+
314+ # to check feedback comments are saved like enrypted data
315+ self .assertNotEqual (feedback .comments , comments )
316+
317+ self .assertEqual (check_comments (feedback .comments , comments , self .privatekey_file ), True )
318+ Nomination .objects .get (position = position ,
319+ candidate_name = candidate_name ,
320+ candidate_email = candidate_email ,
321+ candidate_phone = candidate_phone ,
322+ nominee = nominee ,
323+ comments = feedback ,
324+ nominator_email = "%s%s" % (COMMUNITY_USER , EMAIL_DOMAIN ))
325+
326+ def test_add_questionnaire (self ):
327+ self .access_chair_url (self .private_merge_url )
328+ return self .add_questionnaire ()
329+ self .client .logout ()
330+
331+ def add_questionnaire (self , * args , ** kwargs ):
332+ public = kwargs .pop ('public' , False )
333+ nominee_email = kwargs .pop ('nominee_email' , u'nominee@example.com' )
334+ nominator_email = kwargs .pop ('nominator_email' , "%s%s" % (COMMUNITY_USER , EMAIL_DOMAIN ))
335+ position_name = kwargs .pop ('position' , 'IAOC' )
336+
266337 self .nominate_view (public = public ,
267338 nominee_email = nominee_email ,
268339 position = position_name ,
269340 nominator_email = nominator_email )
270341
271- feedback_url = self .public_feedback_url
272- if not public :
273- feedback_url = self .private_feedback_url
274-
275- response = self .client .get (feedback_url )
342+ response = self .client .get (self .add_questionnaire_url )
276343 self .assertEqual (response .status_code , 200 )
277344
278345 nomcom = get_nomcom_by_year (self .year )
279346 if not nomcom .public_key :
280- self .assertNotContains (response , "feedbackform " )
347+ self .assertNotContains (response , "questionnnaireform " )
281348
282349 # save the cert file in tmp
283350 nomcom .public_key .storage .location = tempfile .gettempdir ()
284351 nomcom .public_key .save ('cert' , File (open (self .cert_file .name , 'r' )))
285352
286- response = self .client .get (feedback_url )
353+ response = self .client .get (self . add_questionnaire_url )
287354 self .assertEqual (response .status_code , 200 )
288- self .assertContains (response , "feedbackform " )
355+ self .assertContains (response , "questionnnaireform " )
289356
290357 position = Position .objects .get (name = position_name )
291358 nominee = Nominee .objects .get (email__address = nominee_email )
292359
293- comments = 'test feedback view'
360+ comments = 'test add questionnaire view'
294361
295362 test_data = {'comments' : comments ,
296- 'position_name' : position .name ,
297- 'nominee_name' : nominee .email .person .name ,
298- 'nominee_email' : nominee .email .address }
299-
300- if public :
301- test_data ['nominator_email' ] = nominator_email
302- test_data ['nominator_name' ] = nominator_email
303-
304- feedback_url += "?nominee=%d&position=%d" % (nominee .id , position .id )
363+ 'positions' : [position .id ],
364+ 'nominee' : nominee .id }
305365
306- response = self .client .post (feedback_url , test_data )
366+ response = self .client .post (self . add_questionnaire_url , test_data )
307367
308368 self .assertEqual (response .status_code , 200 )
309369 self .assertContains (response , "info-message-success" )
310370
311371 ## check objects
312372 feedback = Feedback .objects .get (positions__in = [position ],
313373 nominee = nominee ,
314- type = FeedbackType .objects .get (slug = 'comment' ))
315- if public :
316- self .assertEqual (feedback .author , nominator_email )
374+ type = FeedbackType .objects .get (slug = 'questio' ))
317375
318376 ## to check feedback comments are saved like enrypted data
319377 self .assertNotEqual (feedback .comments , comments )
320378
321379 self .assertEqual (check_comments (feedback .comments , comments , self .privatekey_file ), True )
322380
323- def test_public_nominate (self ):
324- login_testing_unauthorized (self , COMMUNITY_USER , self .public_nominate_url )
325- return self .nominate_view (public = True )
381+ def test_public_feedback (self ):
382+ login_testing_unauthorized (self , COMMUNITY_USER , self .public_feedback_url )
383+ return self .feedback_view (public = True )
326384 self .client .logout ()
327385
328- def test_private_nominate (self ):
329- self .access_member_url (self .private_nominate_url )
330- return self .nominate_view (public = False )
386+ def test_private_feedback (self ):
387+ self .access_member_url (self .private_feedback_url )
388+ return self .feedback_view (public = False )
331389 self .client .logout ()
332390
333- def nominate_view (self , * args , ** kwargs ):
391+ def feedback_view (self , * args , ** kwargs ):
334392 public = kwargs .pop ('public' , True )
335393 nominee_email = kwargs .pop ('nominee_email' , u'nominee@example.com' )
336394 nominator_email = kwargs .pop ('nominator_email' , "%s%s" % (COMMUNITY_USER , EMAIL_DOMAIN ))
337395 position_name = kwargs .pop ('position' , 'IAOC' )
338396
339- if public :
340- nominate_url = self .public_nominate_url
341- else :
342- nominate_url = self .private_nominate_url
343- response = self .client .get (nominate_url )
397+ self .nominate_view (public = public ,
398+ nominee_email = nominee_email ,
399+ position = position_name ,
400+ nominator_email = nominator_email )
401+
402+ feedback_url = self .public_feedback_url
403+ if not public :
404+ feedback_url = self .private_feedback_url
405+
406+ response = self .client .get (feedback_url )
344407 self .assertEqual (response .status_code , 200 )
345408
346409 nomcom = get_nomcom_by_year (self .year )
347410 if not nomcom .public_key :
348- self .assertNotContains (response , "nominateform " )
411+ self .assertNotContains (response , "feedbackform " )
349412
350413 # save the cert file in tmp
351414 nomcom .public_key .storage .location = tempfile .gettempdir ()
352415 nomcom .public_key .save ('cert' , File (open (self .cert_file .name , 'r' )))
353416
354- response = self .client .get (nominate_url )
417+ response = self .client .get (feedback_url )
355418 self .assertEqual (response .status_code , 200 )
356- self .assertContains (response , "nominateform " )
419+ self .assertContains (response , "feedbackform " )
357420
358421 position = Position .objects .get (name = position_name )
359- candidate_email = nominee_email
360- candidate_name = u'nominee'
361- comments = 'test nominate view'
362- candidate_phone = u'123456'
422+ nominee = Nominee .objects .get (email__address = nominee_email )
363423
364- test_data = {'candidate_name' : candidate_name ,
365- 'candidate_email' : candidate_email ,
366- 'candidate_phone' : candidate_phone ,
367- 'position' : position .id ,
368- 'comments' : comments }
369- if not public :
424+ comments = 'test feedback view'
425+
426+ test_data = {'comments' : comments ,
427+ 'position_name' : position .name ,
428+ 'nominee_name' : nominee .email .person .name ,
429+ 'nominee_email' : nominee .email .address }
430+
431+ if public :
370432 test_data ['nominator_email' ] = nominator_email
433+ test_data ['nominator_name' ] = nominator_email
434+
435+ feedback_url += "?nominee=%d&position=%d" % (nominee .id , position .id )
436+
437+ response = self .client .post (feedback_url , test_data )
371438
372- response = self .client .post (nominate_url , test_data )
373439 self .assertEqual (response .status_code , 200 )
374440 self .assertContains (response , "info-message-success" )
375441
376- # check objects
377- email = Email .objects .get (address = candidate_email )
378- Person .objects .get (name = candidate_name , address = candidate_email )
379- nominee = Nominee .objects .get (email = email )
380- NomineePosition .objects .get (position = position , nominee = nominee )
442+ ## check objects
381443 feedback = Feedback .objects .get (positions__in = [position ],
382444 nominee = nominee ,
383- type = FeedbackType .objects .get (slug = 'nomina' ),
384- author = nominator_email )
445+ type = FeedbackType .objects .get (slug = 'comment' ))
446+ if public :
447+ self .assertEqual (feedback .author , nominator_email )
385448
386- # to check feedback comments are saved like enrypted data
449+ ## to check feedback comments are saved like enrypted data
387450 self .assertNotEqual (feedback .comments , comments )
388451
389452 self .assertEqual (check_comments (feedback .comments , comments , self .privatekey_file ), True )
390- Nomination .objects .get (position = position ,
391- candidate_name = candidate_name ,
392- candidate_email = candidate_email ,
393- candidate_phone = candidate_phone ,
394- nominee = nominee ,
395- comments = feedback ,
396- nominator_email = "%s%s" % (COMMUNITY_USER , EMAIL_DOMAIN ))
397453
398454
399455class NomineePositionStateSaveTest (TestCase ):
0 commit comments