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_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(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])
template_name='elections/compare_candidates.html')), name='face_to_face_two_candidates_detail_view'), #one candidate for compare url(r'^eleccion/(?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'^eleccion/(?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'^eleccion/(?P<slug>[-\w]+)/soul-mate/?$', csrf_exempt( SoulMateDetailView.as_view( template_name='elections/soulmate_candidate.html')), name='soul_mate_detail_view'), #soulmate url(r'^eleccion/(?P<slug>[-\w]+)/embedded-soul-mate/?$', xframe_options_exempt( csrf_exempt( SoulMateDetailView.as_view( template_name='elections/soulmate_candidate.html', layout="elections/embedded.html"))), name='embedded_soul_mate_detail_view'), url(r'^eleccion/(?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'^eleccion/(?P<election_slug>[-\w]+)/(?P<slug>[-\w]+)/(?P<url>[-\w]+)/?$',
name='questionary_detail_view'), #compare two candidates url(r'^eleccion/(?P<slug>[-\w]+)/face-to-face/(?P<slug_candidate_one>[-\w]+)/(?P<slug_candidate_two>[-\w]+)/?$', 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'^eleccion/(?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'^eleccion/(?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'^eleccion/(?P<slug>[-\w]+)/soul-mate/?$', csrf_exempt(SoulMateDetailView.as_view(template_name='elections/soulmate_candidate.html')), name='soul_mate_detail_view'), #soulmate url(r'^eleccion/(?P<slug>[-\w]+)/embedded-soul-mate/?$', xframe_options_exempt(csrf_exempt(SoulMateDetailView.as_view(template_name='elections/soulmate_candidate.html', layout="elections/embedded.html"))), name='embedded_soul_mate_detail_view'), url(r'^eleccion/(?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' ), url(r'^candidaturas/(?P<area_slug>[-\w]+)/(?P<slug>[-\w]+)/?$', cache_page(60 * settings.CACHE_MINUTES)(CandidateDetailView.as_view(template_name='elections/candidate_detail.html')), name='candidate_detail_view_area' ), # End Preguntales