def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
     self.other_election = ElectionFactory.create()
     self.wrong_pk = self.other_election.pk + 1
     self.url = reverse('elections:election_delete',
                        args=(self.election.pk, ))
 def test_list_own_elections(self):
     ElectionFactory.create()
     user = self.login()
     ElectionFactory.create(user=user)
     response = self.client.get(self.get_url())
     self.assertEqual(
         len(response.context['elections']),
         1
     )
    def setUp(self):
        self.file_election = ElectionFactory.create()
        self.file_cs = CandidateFactory.create_batch(4, election=self.file_election)
        self.file_vs = VoterFactory.create_batch(10, election=self.file_election)
        self.file_url = reverse('elections:chart_data', args=(self.file_election.pk,))

        self.gauss_election = ElectionFactory.create()
        self.gauss_cs = PointCandidateFactory.create_batch(4, election=self.gauss_election)
        self.gauss_vs = PointVoterFactory.create_batch(10, election=self.gauss_election)
        self.gauss_url = reverse('elections:chart_data', args=(self.gauss_election.pk,))
    def test_is_set_generated_flag(self):
        empty_election = ElectionFactory.create()

        file_election = ElectionFactory.create()
        file_cs = CandidateFactory.create_batch(4, election=file_election)
        file_vs = VoterFactory.create_batch(10, election=file_election)

        gauss_election = ElectionFactory.create()
        gauss_cs = PointCandidateFactory.create_batch(4, election=gauss_election)
        gauss_vs = PointVoterFactory.create_batch(10, election=gauss_election)

        self.assertEqual(empty_election.is_generated(), False)
        self.assertEqual(file_election.is_generated(), False)
        self.assertEqual(gauss_election.is_generated(), True)
 def test_is_set_up_flag(self):
     election = ElectionFactory.create()
     self.assertEqual(election.is_set_up(), False)
     VoterFactory.create(election=election)
     self.assertEqual(election.is_set_up(), False)
     CandidateFactory.create(election=election)
     self.assertEqual(election.is_set_up(), True)
    def setUp(self):
        self.file_election = ElectionFactory.create()
        self.file_cs = CandidateFactory.create_batch(
            4, election=self.file_election)
        self.file_vs = VoterFactory.create_batch(10,
                                                 election=self.file_election)
        self.file_url = reverse('elections:chart_data',
                                args=(self.file_election.pk, ))

        self.gauss_election = ElectionFactory.create()
        self.gauss_cs = PointCandidateFactory.create_batch(
            4, election=self.gauss_election)
        self.gauss_vs = PointVoterFactory.create_batch(
            10, election=self.gauss_election)
        self.gauss_url = reverse('elections:chart_data',
                                 args=(self.gauss_election.pk, ))
 def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
     self.result_to_delete = ResultFactory.create(election=self.election)
     self.other_result = ResultFactory.create()
     self.url = reverse('elections:result_delete',
                        args=(self.result_to_delete.pk, ))
 def setUp(self):
     self.election = ElectionFactory.create()
     self.candidates = PointCandidateFactory.create_batch(4, election=self.election)
     self.voters = PointVoterFactory.create_batch(10, election=self.election)
     self.result = ResultFactory.create(election=self.election)
     self.result.winners.add(self.candidates[0])
     self.result.winners.add(self.candidates[1])
     self.url = reverse('elections:result_chart_data', args=(self.result.pk,))
 def setUp(self):
     self.election = ElectionFactory.create()
     self.candidates_amount = 10
     self.voters_amount = 10
     self.generator = ElectionGenerator(self.election,
                                        self.candidates_amount,
                                        self.voters_amount, 0, 0, 10, 0, 0,
                                        10)
 def setUp(self):
     self.election = ElectionFactory.create(committee_size=2)
     self.candidates = CandidateFactory.create_batch(3,
                                                     election=self.election)
     self.voters = VoterFactory.create_batch(3, election=self.election)
     for voter in self.voters:
         for candidate in self.candidates:
             PreferenceFactory.create(voter=voter, candidate=candidate)
     self.p_parameter = 2
     self.algorithm = BruteForce(self.election, self.p_parameter)
 def setUp(self):
     self.election = ElectionFactory.create()
     self.candidates_amount = 10
     self.voters_amount = 10
     self.generator = ElectionGenerator(
         self.election,
         self.candidates_amount, self.voters_amount,
         0, 0, 10,
         0, 0, 10
     )
 def setUp(self):
     self.election = ElectionFactory.create(committee_size=2)
     self.candidates = CandidateFactory.create_batch(3, election=self.election)
     self.voters = VoterFactory.create_batch(3, election=self.election)
     for voter in self.voters:
         for candidate in self.candidates:
             PreferenceFactory.create(
                 voter=voter, candidate=candidate
             )
     self.p_parameter = 2
     self.algorithm = BruteForce(self.election, self.p_parameter)
 def setUp(self):
     self.election = ElectionFactory.create(committee_size=2)
     self.candidates = CandidateFactory.create_batch(3,
                                                     election=self.election)
     self.voters = VoterFactory.create_batch(3, election=self.election)
     self.satisfaction = {}
     for voter in self.voters:
         self.satisfaction[voter.pk] = 56
         for candidate in self.candidates:
             PreferenceFactory.create(voter=voter, candidate=candidate)
     self.algorithm = GreedyAlgorithm(self.election, 2)
 def setUp(self):
     self.election = ElectionFactory.create()
     self.candidates = PointCandidateFactory.create_batch(
         4, election=self.election)
     self.voters = PointVoterFactory.create_batch(10,
                                                  election=self.election)
     self.result = ResultFactory.create(election=self.election)
     self.result.winners.add(self.candidates[0])
     self.result.winners.add(self.candidates[1])
     self.url = reverse('elections:result_chart_data',
                        args=(self.result.pk, ))
 def setUp(self):
     self.election = ElectionFactory.create(committee_size=2)
     self.candidates = CandidateFactory.create_batch(3, election=self.election)
     self.voters = VoterFactory.create_batch(3, election=self.election)
     self.satisfaction = {}
     for voter in self.voters:
         self.satisfaction[voter.pk] = 56
         for candidate in self.candidates:
             PreferenceFactory.create(
                 voter=voter, candidate=candidate
             )
     self.algorithm = GreedyCC(self.election, 2)
 def setUp(self):
     self.election = ElectionFactory.create(committee_size=2)
     self.candidates = CandidateFactory.create_batch(6, election=self.election)
     self.voters = VoterFactory.create_batch(3, election=self.election)
     for voter in self.voters:
         for candidate in self.candidates:
             PreferenceFactory.create(
                 voter=voter, candidate=candidate
             )
     self.p_parameter = 2
     self.cycles = 10
     self.algorithm = GeneticAlgorithm(self.election, self.p_parameter, **{
         'mutation_probability': 10,
         'crossing_probability': 50,
         'cycles': self.cycles,
     })
 def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
     self.other_election = ElectionFactory.create()
     self.wrong_pk = self.other_election.pk + 1
     self.url = reverse('elections:election_delete', args=(self.election.pk,))
 def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
     self.result_to_delete = ResultFactory.create(election=self.election)
     self.other_result = ResultFactory.create()
     self.url = reverse('elections:result_delete', args=(self.result_to_delete.pk,))
 def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
     self.url = reverse('elections:result_create',
                        args=(self.election.pk, ))
 def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
     self.url = reverse('elections:result_create', args=(self.election.pk,))
 def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
     self.url = reverse('elections:election_load_data', args=(self.election.pk,))
 def test_list_own_elections(self):
     ElectionFactory.create()
     user = self.login()
     ElectionFactory.create(user=user)
     response = self.client.get(self.get_url())
     self.assertEqual(len(response.context['elections']), 1)
 def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
 def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
     self.url = reverse('elections:election_load_data',
                        args=(self.election.pk, ))
 def setUp(self):
     self.user = self.login()
     self.election = ElectionFactory.create(user=self.user)
 def setUp(self):
     self.election = ElectionFactory.create()
     self.result = ResultFactory.create(election=self.election)
     self.url = reverse('elections:algorithms_chart_data', args=(self.result.pk,))
Example #27
0
 def setUp(self):
     self.election = ElectionFactory.create(committee_size=2)
     CandidateFactory.create_batch(3, election=self.election)
     self.algorithm = Algorithm(self.election, 1)
 def setUp(self):
     self.election = ElectionFactory.create()
     self.result = ResultFactory.create(election=self.election)
     self.url = reverse('elections:algorithms_chart_data',
                        args=(self.result.pk, ))