Skip to content

Commit

Permalink
Merge pull request #4 from benhovinga/fix_flake8_E501_line_too_long
Browse files Browse the repository at this point in the history
Fix flake8 E501 line too long errors batch 1
  • Loading branch information
benhovinga authored Dec 31, 2023
2 parents 9b0500e + 064b09b commit f3bdbbc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
10 changes: 7 additions & 3 deletions aamva_standard/issuing_authority.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class IssuingAuthority:


ISSUING_AUTHORITIES = (
# Source:
# https://www.aamva.org/identity/issuer-identification-numbers-(iin)
IssuingAuthority(604426, "Prince Edward Island", "PE", "Canada"),
IssuingAuthority(604427, "American Samoa", "AS", "USA"),
IssuingAuthority(604428, "Quebec", "GC", "Canada"),
Expand Down Expand Up @@ -83,12 +85,14 @@ class IssuingAuthority:
IssuingAuthority(636061, "West Virginia", "WV", "USA"),
IssuingAuthority(636062, "Virgin Islands", "VI", "USA"),
)
"""Source: https://www.aamva.org/identity/issuer-identification-numbers-(iin)"""


def get_authority_by_id(id_number: int) -> IssuingAuthority:
try:
_map = tuple(filter(lambda i: i.issuer_identification_number == id_number, ISSUING_AUTHORITIES))[0]
issuing_authority = tuple(
filter(
lambda i: i.issuer_identification_number == id_number,
ISSUING_AUTHORITIES))[0]
except IndexError:
raise KeyError(f"id_number: {id_number}, not found")
return _map
return issuing_authority
13 changes: 11 additions & 2 deletions aamva_standard/test_barcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
# ((test_string, designators, expects), ...)
(
# AAMVA Version 1
"@\n\x1e\rANSI 6360000102DL00390187ZV02260032DLDAQ0123456789ABC\nDAAPUBLIC,JOHN,Q\nDAG123 MAIN STREET\nDAIANYTOWN\nDAJVA\nDAK123459999 \nDARDM \nDAS \nDAT \nDAU509\nDAW175\nDAYBL \nDAZBR \nDBA20011201\nDBB19761123\nDBCM\nDBD19961201\rZVZVAJURISDICTIONDEFINEDELEMENT\r",
"@\n\x1e\rANSI 6360000102DL00390187ZV02260032DLDAQ0123456789ABC\n" +
"DAAPUBLIC,JOHN,Q\nDAG123 MAIN STREET\nDAIANYTOWN\nDAJVA\n" +
"DAK123459999 \nDARDM \nDAS \nDAT \nDAU509\nDAW175\n" +
"DAYBL \nDAZBR \nDBA20011201\nDBB19761123\nDBCM\nDBD19961201\r" +
"ZVZVAJURISDICTIONDEFINEDELEMENT\r",
(
("DL", 39, 187),
("ZV", 226, 32)
Expand Down Expand Up @@ -49,7 +53,12 @@
),
(
# AAMVA Version 10
"@\n\x1e\rANSI 636000100102DL00410278ZV03190008DLDAQT64235789\nDCSSAMPLE\nDDEN\nDACMICHAEL\nDDFN\nDADJOHN\nDDGN\nDCUJR\nDCAD\nDCBK\nDCDPH\nDBD06062019\nDBB06061986\nDBA12102024\nDBC1\nDAU068 in\nDAYBRO\nDAG2300 WEST BROAD STREET\nDAIRICHMOND\nDAJVA\nDAK232690000 \nDCF2424244747474786102204\nDCGUSA\nDCK123456789\nDDAF\nDDB06062018\nDDC06062020\nDDD1\rZVZVA01\r",
"@\n\x1e\rANSI 636000100102DL00410278ZV03190008DLDAQT64235789\n" +
"DCSSAMPLE\nDDEN\nDACMICHAEL\nDDFN\nDADJOHN\nDDGN\nDCUJR\nDCAD\n" +
"DCBK\nDCDPH\nDBD06062019\nDBB06061986\nDBA12102024\nDBC1\n" +
"DAU068 in\nDAYBRO\nDAG2300 WEST BROAD STREET\nDAIRICHMOND\nDAJVA\n" +
"DAK232690000 \nDCF2424244747474786102204\nDCGUSA\nDCK123456789\n" +
"DDAF\nDDB06062018\nDDC06062020\nDDD1\rZVZVA01\r",
(
("DL", 41, 278),
("ZV", 319, 8)
Expand Down
25 changes: 15 additions & 10 deletions aamva_standard/test_issuing_authority.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@


@pytest.fixture
def authority_list():
def issuing_authorities_testdata():
return (
issuing_authority.IssuingAuthority(100001, "Test Jurisdiction 1", "T1", "Canada"),
issuing_authority.IssuingAuthority(100002, "Test Jurisdiction 2", "T2", "USA")
issuing_authority.IssuingAuthority(
100001, "Test Jurisdiction 1", "T1", "Canada"),
issuing_authority.IssuingAuthority(
100002, "Test Jurisdiction 2", "T2", "USA")
)


@pytest.fixture
def fake_authority_list(authority_list):
saved_list = issuing_authority.ISSUING_AUTHORITIES
issuing_authority.ISSUING_AUTHORITIES = authority_list
def fake_authority_list(issuing_authorities_testdata):
saved_authorities = issuing_authority.ISSUING_AUTHORITIES
issuing_authority.ISSUING_AUTHORITIES = issuing_authorities_testdata
yield None
issuing_authority.ISSUING_AUTHORITIES = saved_list
issuing_authority.ISSUING_AUTHORITIES = saved_authorities


def test_get_authority_by_id(fake_authority_list, authority_list):
assert issuing_authority.get_authority_by_id(100001) == authority_list[0]
assert issuing_authority.get_authority_by_id(100002) == authority_list[1]
def test_get_authority_by_id(
fake_authority_list, issuing_authorities_testdata):
assert (issuing_authority.get_authority_by_id(100001) ==
issuing_authorities_testdata[0])
assert (issuing_authority.get_authority_by_id(100002) ==
issuing_authorities_testdata[1])
with pytest.raises(KeyError, match="not found"):
issuing_authority.get_authority_by_id(1)

0 comments on commit f3bdbbc

Please sign in to comment.