コード例 #1
0
    def setUp(self, mock_requests):
        mock_requests.get.side_effect = fake_requests_current_elections

        self.ee_importer = every_election.EveryElectionImporter()
        self.ee_importer.build_election_tree()

        self.parent_id = "local.brent.2018-02-22"  # they're good elections
        self.child_id = "local.brent.alperton.2018-02-22"
コード例 #2
0
    def test_create_from_all_elections(self, mock_requests):
        mock_requests.get.side_effect = fake_requests_current_elections
        query_args = {"poll_open_date": "2019-01-17", "current": "True"}
        self.ee_importer = every_election.EveryElectionImporter(query_args)
        self.ee_importer.build_election_tree()

        for ballot_id, election_dict in self.ee_importer.ballot_ids.items():
            parent = self.ee_importer.get_parent(ballot_id)
            election_dict.get_or_create_post_election(parent=parent)
        self.assertEqual(every_election.Post.objects.all().count(), 11)
        self.assertEqual(every_election.YNRElection.objects.all().count(), 10)
コード例 #3
0
    def test_create_from_all_elections(self, mock_requests):
        mock_requests.get.side_effect = fake_requests_for_every_election
        query_args = {
            'poll_open_date': '2019-01-17',
            'current': 'True',
        }
        self.ee_importer = every_election.EveryElectionImporter(query_args)
        self.ee_importer.build_election_tree()

        for ballot_id, election_dict in self.ee_importer.ballot_ids.items():
            parent = self.ee_importer.get_parent(ballot_id)
            election_dict.get_or_create_post_election(parent=parent)
        self.assertEqual(every_election.PostExtra.objects.all().count(), 11)
        self.assertEqual(every_election.YNRElection.objects.all().count(), 10)
        self.assertEqual(check_constraints(), [])