def handle(self, verbosity: int, **_kwargs): log.init(verbosity=verbosity if '-v' in sys.argv else 2) defaults.initialize_parties() defaults.initialize_districts() self.update_elections() self.update_jurisdictions()
def with_active_election_and_one_scrapped_ballot(expect, active_election): defaults.initialize_districts() defaults.initialize_parties() commands.scrape_ballots(starting_precinct_id=1828, ballot_limit=1) commands.parse_ballots() expect(Ballot.objects.count()) == 1 expect(District.objects.count()) == 7
def parse_ballot(election_id: int, precinct_id: int) -> int: defaults.initialize_districts() defaults.initialize_parties() website, _ = BallotWebsite.objects.get_or_create( mvic_election_id=election_id, mvic_precinct_id=precinct_id ) website.fetch() website.validate() website.scrape() ballot = website.convert() ballot.website = website return ballot.parse()
def handle(self, verbosity: int, **_kwargs): # type: ignore log.reset() log.silence("datafiles") log.init(verbosity=verbosity if "-v" in sys.argv[-1] else 2) defaults.initialize_parties() defaults.initialize_districts() self.update_elections() self.update_jurisdictions() self.update_candidates() self.import_descriptions() self.export_descriptions()
def test_ballots(expect, db, election_id, precinct_id, item_count): defaults.initialize_districts() defaults.initialize_parties() website = BallotWebsite.objects.create( mi_sos_election_id=election_id, mi_sos_precinct_id=precinct_id ) website.fetch() website.validate() website.scrape() website.convert() ballot = website.convert() ballot.website = website expect(ballot.parse()) == item_count
def it_can_be_called_multiple_times(expect, db): defaults.initialize_parties() defaults.initialize_parties() expect(Party.objects.count()) == 9