Example #1
0
    def handle(self, verbosity: int, refetch: bool, **_kwargs):
        log.init(verbosity=verbosity if '-v' in sys.argv else 2)

        # https://github.com/citizenlabsgr/elections-api/issues/81
        warnings.simplefilter('once')

        parse_ballots(refetch=refetch)
    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 handle(self, verbosity: int, election: Optional[int], **_kwargs):  # type: ignore
        log.reset()
        log.silence("datafiles")
        log.init(reset=True, verbosity=verbosity if "-v" in sys.argv[-1] else 2)

        try:
            parse_ballots(election_id=election)
        except Exception as e:
            if "HEROKU_APP_NAME" in os.environ:
                log.error("Unable to finish parsing data", exc_info=e)
                bugsnag.notify(e)
                sys.exit(1)
            else:
                raise e from None
    def with_active_election_and_no_scrapped_ballots(expect, active_election):
        commands.parse_ballots()

        expect(Ballot.objects.count()) == 0
    def with_no_active_election(expect, db):
        commands.parse_ballots()

        expect(Ballot.objects.count()) == 0