Skip to content
This repository was archived by the owner on Jan 8, 2025. It is now read-only.

Commit d5fda26

Browse files
authored
Fix #155 - implement a daily cronjob to test it (#237)
1 parent e451154 commit d5fda26

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: pypi test cronjob (download idnumbers from pypi)
2+
3+
on:
4+
schedule:
5+
- cron: '5 1 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up Python 3.9
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.9"
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
23+
pip install idnumbers
24+
- name: Test with python pypi_spec
25+
run: |
26+
python -m tests.pypi_spec

tests/pypi_spec.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from idnumbers.nationalid import AUS, NGA, ZAF
2+
3+
4+
def validate_test():
5+
# Verify AUS tax file number (with checksum code)
6+
taxfile_number = '32547689'
7+
is_valid = AUS.TaxFileNumber.validate(taxfile_number)
8+
assert is_valid
9+
if is_valid:
10+
print(f'{taxfile_number} is a valid AUS Tax File Number')
11+
else:
12+
print(f'{taxfile_number} is an invalid AUS Tax File Number')
13+
14+
# Verify AUS driver license number
15+
driver_license = '12 345 678'
16+
is_valid = AUS.DriverLicenseNumber.validate(driver_license)
17+
assert is_valid
18+
if is_valid:
19+
print(f'{driver_license} is a valid AUS Driver License Number')
20+
else:
21+
print(f'{driver_license} is an invalid AUS Driver License Number')
22+
23+
# Verify AUS Medicare number (with checksum code)
24+
medicare_number = '2123 45670 1'
25+
is_valid = AUS.MedicareNumber.validate(medicare_number)
26+
assert is_valid
27+
if is_valid:
28+
print(f'{medicare_number} is a valid AUS Medicare Number')
29+
else:
30+
print(f'{medicare_number} is an invalid AUS Medicare Number')
31+
32+
# Verify NGA national id number
33+
nga_nationalid = '12345678901'
34+
is_valid = NGA.NationalID.validate(nga_nationalid)
35+
assert is_valid
36+
if is_valid:
37+
print(f'{nga_nationalid} is a valid Nigerian National ID Number')
38+
else:
39+
print(f'{nga_nationalid} is an invalid Nigerian National ID Number')
40+
41+
# Verify ZAF nation id number
42+
zaf_nationalid = '7605300675088'
43+
is_valid = ZAF.NationalID.validate(zaf_nationalid)
44+
assert is_valid
45+
if is_valid:
46+
print(f'{zaf_nationalid} is a valid South African ID Number')
47+
else:
48+
print(f'{zaf_nationalid} is an invalid South African ID Number')
49+
50+
51+
def parse_test():
52+
id_number = '7605300675088'
53+
id_data = ZAF.NationalID.parse(id_number)
54+
assert id_data is not None
55+
56+
# Access the date of birth
57+
print(f'Date of birth: {id_data["yyyymmdd"]}')
58+
59+
# Access the gender
60+
print(f'Gender: {id_data["gender"]}')
61+
62+
# Access the citizenship
63+
print(f'Citizenship: {id_data["citizenship"]}')
64+
65+
66+
if __name__ == '__main__':
67+
print('run validate test')
68+
validate_test()
69+
print('run parse test')
70+
parse_test()

0 commit comments

Comments
 (0)