def test_view_determine_the_choices(self): view = SoulMateDetailView() data = { "question-0": "8", "question-1": "11", "question-2": "14", "question-id-0": "4", "question-id-1": "5", "question-id-2": "6" } taken_positions = view.determine_taken_positions(data) self.assertEquals(len(taken_positions), 3) self.assertIsInstance(taken_positions[0], TakenPosition) self.assertIsInstance(taken_positions[1], TakenPosition) self.assertIsInstance(taken_positions[2], TakenPosition) fiera_topic = Topic.objects.get(id=4) si_fiera = Position.objects.get(id=8) self.assertEquals(taken_positions[0].topic, fiera_topic) self.assertEquals(taken_positions[0].position, si_fiera) with self.assertRaises(Person.DoesNotExist): taken_positions[0].person benito_topic = Topic.objects.get(id=5) si_benito = Position.objects.get(id=11) self.assertEquals(taken_positions[1].topic, benito_topic) self.assertEquals(taken_positions[1].position, si_benito) with self.assertRaises(Person.DoesNotExist): taken_positions[1].person freedom_topic = Topic.objects.get(id=6) no_freedom = Position.objects.get(id=14) self.assertEquals(taken_positions[2].topic, freedom_topic) self.assertEquals(taken_positions[2].position, no_freedom) with self.assertRaises(Person.DoesNotExist): taken_positions[2].person
def test_get_information_holder_with_positions(self): view = SoulMateDetailView() view.object = self.antofa data = { "question-0": "8", "question-1": "11", "question-2": "14", "question-id-0": "4", "question-id-1": "5", "question-id-2": "6" } holder = view.get_information_holder(data=data) for candidate in holder.persons: self.assertIsInstance(candidate, Candidate) self.assertIn(int(candidate.id), [1, 2, 3]) for category in holder.categories: self.assertIsInstance(category, QuestionCategory) self.assertIn(int(category.id), [3, 4]) for position_id in holder.positions: self.assertIsInstance(holder.positions[position_id], TakenPosition) self.assertIn(int(holder.positions[position_id].topic.id), [4, 5, 6]) self.assertIn(int(holder.positions[position_id].position.id), [8, 11, 14]) with self.assertRaises(Person.DoesNotExist): holder.positions[position_id].person
def test_get_information_holder(self): view = SoulMateDetailView() view.object = self.antofa holder = view.get_information_holder() self.assertIsInstance(holder, InformationHolder) for candidate in holder.persons: self.assertIsInstance(candidate, Candidate) self.assertIn(int(candidate.id), [1, 2, 3]) for category in holder.categories: self.assertIsInstance(category, QuestionCategory) self.assertIn(int(category.id), [3, 4])
name='questionary_detail_view'), #compare two candidates url(r'^election/(?P<slug>[-\w]+)/face-to-face/(?P<slug_candidate_one>[-\w]+)/(?P<slug_candidate_two>[-\w]+)/?$', cache_page(FaceToFaceView.as_view(template_name='elections/compare_candidates.html'), 60 * settings.CACHE_MINUTES), name='face_to_face_two_candidates_detail_view'), #one candidate for compare url(r'^election/(?P<slug>[-\w]+)/face-to-face/(?P<slug_candidate_one>[-\w]+)/?$', cache_page(ElectionDetailView.as_view(template_name='elections/compare_candidates.html'), 60 * settings.CACHE_MINUTES), name='face_to_face_one_candidate_detail_view'), #no one candidate url(r'^election/(?P<slug>[-\w]+)/face-to-face/?$', cache_page(ElectionDetailView.as_view(template_name='elections/compare_candidates.html'), 60 * settings.CACHE_MINUTES), name='face_to_face_no_candidate_detail_view'), #soulmate url(r'^election/(?P<slug>[-\w]+)/soul-mate/?$', SoulMateDetailView.as_view(template_name='elections/soulmate_candidate.html'), name='soul_mate_detail_view'), #ask url(r'^election/(?P<slug>[-\w]+)/ask/?$', ElectionAskCreateView.as_view(template_name='elections/ask_candidate.html'), name='ask_detail_view'), #ranking url(r'^election/(?P<slug>[-\w]+)/ranking/?$', cache_page(ElectionRankingView.as_view(template_name='elections/ranking_candidates.html'), 60 * settings.CACHE_MINUTES), name='ranking_detail_view'), url(r'^election/(?P<election_slug>[-\w]+)/(?P<slug>[-\w]+)/?$', cache_page(CandidateDetailView.as_view(template_name='elections/candidate_detail.html'), 60 * settings.CACHE_MINUTES), name='candidate_detail_view' ), url(r'^election/(?P<election_slug>[-\w]+)/(?P<slug>[-\w]+)/questions?$', QuestionsPerCandidateView.as_view(template_name='elections/questions_per_candidate.html'),
cache_page(60 * settings.CACHE_MINUTES)(FaceToFaceView.as_view( template_name='elections/compare_candidates.html')), name='face_to_face_two_candidates_detail_view'), #one candidate for compare url(r'^election/(?P<slug>[-\w]+)/face-to-face/(?P<slug_candidate_one>[-\w]+)/?$', cache_page(60 * settings.CACHE_MINUTES)(ElectionDetailView.as_view( template_name='elections/compare_candidates.html')), name='face_to_face_one_candidate_detail_view'), #no one candidate url(r'^election/(?P<slug>[-\w]+)/face-to-face/?$', cache_page(60 * settings.CACHE_MINUTES)(ElectionDetailView.as_view( template_name='elections/compare_candidates.html')), name='face_to_face_no_candidate_detail_view'), #soulmate url(r'^election/(?P<slug>[-\w]+)/soul-mate/?$', SoulMateDetailView.as_view( template_name='elections/soulmate_candidate.html'), name='soul_mate_detail_view'), url(r'^election/(?P<election_slug>[-\w]+)/(?P<slug>[-\w]+)/?$', cache_page(60 * settings.CACHE_MINUTES)(CandidateDetailView.as_view( template_name='elections/candidate_detail.html')), name='candidate_detail_view'), # End Preguntales url(r'^election/(?P<election_slug>[-\w]+)/(?P<slug>[-\w]+)/(?P<url>[-\w]+)/?$', cache_page(60 * settings.CACHE_MINUTES)( CandidateFlatPageDetailView.as_view()), name='candidate_flatpage'), url(r'^election/(?P<slug>[-\w]+)/extra_info.html$', ElectionDetailView.as_view(template_name='elections/extra_info.html'), name='election_extra_info'), url(r'^area/(?P<slug>[-\w]+)/?$', AreaDetailView.as_view(template_name='elections/area.html'),