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

DemocracyClub / yournextrepresentative / 06fffc96-31fa-407b-8443-1731e4db6cf1

04 Apr 2024 08:24AM CUT coverage: 68.368% (+1.1%) from 67.282%
06fffc96-31fa-407b-8443-1731e4db6cf1

Pull #2269

circleci

symroe
Clean up some testsing code

Misc fixes to the test code
Pull Request #2269: Redesign SOPN models

1749 of 2922 branches covered (59.86%)

Branch coverage included in aggregate %.

415 of 488 new or added lines in 25 files covered. (85.04%)

18 existing lines in 4 files now uncovered.

7093 of 10011 relevant lines covered (70.85%)

0.71 hits per line

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

66.67
/ynr/apps/sopn_parsing/management/commands/sopn_parsing_extract_page_numbers.py
1
from elections.models import Election
1✔
2
from official_documents.extract_pages import extract_pages_for_election_sopn
1✔
3
from pdfminer.pdftypes import PDFException
1✔
4
from sopn_parsing.helpers.command_helpers import BaseSOPNParsingCommand
1✔
5
from sopn_parsing.helpers.text_helpers import NoTextInDocumentError
1✔
6

7

8
class Command(BaseSOPNParsingCommand):
1✔
9
    help = """
1✔
10
    Parse documents to extract and set relevant pages from documents that have
11
    more than one ballot paper
12

13
    Default is to only parse documents for current electons that haven't
14
    already been parsed. Use `all-documents` and `reparse` to change this.
15

16
    """
17

18
    def handle(self, *args, **options):
1✔
19
        qs = Election.objects.all().exclude(electionsopn=None)
1✔
20

21
        filter_kwargs = {}
1✔
22
        if options.get("election_slugs"):
1!
NEW
23
            filter_kwargs["slug__in"] = options.get("election_slugs").split(",")
×
24

25
        if options["current"]:
1!
NEW
26
            filter_kwargs["current"] = True
×
27

28
        if options["date"]:
1!
NEW
29
            filter_kwargs["election_date"] = options["date"]
×
30

31
        qs = qs.filter(**filter_kwargs)
1✔
32

33
        for election in qs:
1✔
34
            try:
1✔
35
                extract_pages_for_election_sopn(election.electionsopn)
1✔
36
            except (
×
37
                ValueError,
38
                NoTextInDocumentError,
39
                PDFException,
40
                FileNotFoundError,
41
            ) as e:
42
                try:
×
43
                    self.stderr.write(e.args[0])
×
44
                except AttributeError:
×
45
                    self.stderr.write(str(e))
×
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