-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Python Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [2.7, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12', '3.13'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pytest | ||
- name: Run tests | ||
run: | | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
from record import FIASRecord | ||
from exceptions import InvalidRecord, UndefinedRecordType, Ignore | ||
|
||
def test_valid_gi_record(): | ||
record = FIASRecord("GI|G#123|RN101|GNJohn Doe") | ||
assert record.is_valid() | ||
assert record.type == "GI" | ||
assert record.GID == 123 | ||
assert record.RN == "101" | ||
assert record.GN == "John Doe" | ||
|
||
def test_invalid_record(): | ||
with pytest.raises(InvalidRecord): | ||
FIASRecord("InvalidRecord") | ||
|
||
def test_undefined_record_type(): | ||
with pytest.raises(UndefinedRecordType): | ||
record = FIASRecord("XX|G#123|RN101") | ||
record.is_valid(raise_exception=True) | ||
|
||
def test_ignore_record(): | ||
with pytest.raises(Ignore): | ||
record = FIASRecord("DS|SomeData") | ||
record.is_valid(raise_exception=True) | ||
|
||
def test_missing_attributes(): | ||
record = FIASRecord("GI|G#123|RN101") | ||
assert not record.is_valid() | ||
with pytest.raises(InvalidRecord): | ||
record.is_valid(raise_exception=True) |