def handle( # type: ignore self, verbosity: int, start_election: Optional[int], start_precinct: int, ballot_limit: Optional[int], **_kwargs, ): log.reset() log.silence("datafiles") log.init(verbosity=verbosity if "-v" in sys.argv[-1] else 2) try: scrape_ballots( starting_election_id=start_election, starting_precinct_id=start_precinct, ballot_limit=ballot_limit, ) except Exception as e: if "HEROKU_APP_NAME" in os.environ: log.error("Unable to finish scraping data", exc_info=e) bugsnag.notify(e) sys.exit(1) else: raise e from None
def handle(self, verbosity: int, start: int, limit: Optional[int], **_kwargs): log.init(verbosity=verbosity if '-v' in sys.argv else 2) # https://github.com/citizenlabsgr/elections-api/issues/81 warnings.simplefilter('once') scrape_ballots(start=start, limit=limit)
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 with_past_election(expect, past_election): defaults.initialize_districts() commands.scrape_ballots(ballot_limit=1, max_election_error_count=1, max_ballot_error_count=1) expect(Election.objects.count()) == 2 expect(BallotWebsite.objects.count()) == 1
def with_no_active_election(expect, db): commands.scrape_ballots(ballot_limit=1) expect(BallotWebsite.objects.count()) == 0