• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DemocracyClub / yournextrepresentative / 74df76c8-4768-48d5-bb7f-5ee50aa05217

06 Nov 2023 01:38PM UTC coverage: 67.523% (-0.3%) from 67.801%
74df76c8-4768-48d5-bb7f-5ee50aa05217

Pull #2177

circleci

VirginiaDooley
Create TextractResults model
Pull Request #2177: Spike: AWS Textract

1640 of 2760 branches covered (0.0%)

Branch coverage included in aggregate %.

12 of 62 new or added lines in 3 files covered. (19.35%)

110 existing lines in 10 files now uncovered.

6662 of 9535 relevant lines covered (69.87%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/ynr/apps/sopn_parsing/helpers/extract_pages.py
1
from pdfminer.pdftypes import PDFException
1✔
2
from sopn_parsing.helpers.pdf_helpers import SOPNDocument
1✔
3
from sopn_parsing.helpers.text_helpers import NoTextInDocumentError
1✔
4

5

6
def extract_pages_for_ballot(ballot):
1✔
7
    """
8
    Try to extract the page numbers for the latest SOPN document related to this
9
    ballot.
10

11
    Because documents can apply to more than one ballot, we also perform
12
    "drive by" parsing of other ballots contained in a given document.
13

14
    :type ballot: candidates.models.Ballot
15

16
    """
17
    try:
1✔
18
        sopn = SOPNDocument(
1✔
19
            file=ballot.sopn.uploaded_file,
20
            source_url=ballot.sopn.source_url,
21
            election_date=ballot.election.election_date,
22
        )
23
        return sopn.match_all_pages()
1✔
UNCOV
24
    except NoTextInDocumentError:
×
UNCOV
25
        raise NoTextInDocumentError(
×
26
            f"Failed to extract pages for {ballot.sopn.uploaded_file.path} as a NoTextInDocumentError was raised"
27
        )
UNCOV
28
    except PDFException:
×
UNCOV
29
        print(
×
30
            f"{ballot.ballot_paper_id} failed to parse as a PDFSyntaxError was raised"
31
        )
UNCOV
32
        raise PDFException(
×
33
            f"Failed to extract pages for {ballot.sopn.uploaded_file.path} as a PDFSyntaxError was raised"
34
        )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc