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 test_voters_in_context(self):
     v = VoterFactory(election=self.election)
     c = CandidateFactory(election=self.election)
     p = PreferenceFactory(voter=v, candidate=c)
     response = self.client.get(self.get_url())
     self.assertIn('voters', response.context)
     self.assertIn(str(v.repeats), response.content)
     self.assertIn(p.candidate.name, response.content)
 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.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.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(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 = GreedyCC(self.election, 2)
    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 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.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.voter = VoterFactory.create(repeats=1)
     self.preferences = PreferenceFactory.create_batch(5, voter=self.voter)