Skip to content

Commit

Permalink
Add more error cases for EDTF and Hijri parser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Nov 21, 2024
1 parent 11cc007 commit 2cc596e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/test_converters/edtf/test_edtf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"1984-05",
"1984-12",
"1001-03-30",
"1901-02-20",
"1000/2000",
"1000-01/2000-05-01",
# level 1
Expand Down Expand Up @@ -45,7 +46,7 @@ def test_should_parse(date_string):
assert edtf_parser.parse(date_string)


error_cases = ["1984-13", "Y1702"]
error_cases = ["1984-13", "Y1702", "1984-00", "1984-01-00"]


@pytest.mark.parametrize("date_string", error_cases)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,24 @@
@pytest.mark.parametrize("date_string", testcases)
def test_should_parse(date_string):
assert hijri_parser.parse(date_string)


error_cases = [
# invalid days
"0 Muḥarram 1243",
"31 Muḥarram 1243",
# month alone
"Shawwal",
# month day only
"12 Shawwal",
# invalid month
"Foo 383",
# wrong format
"2024-10-02",
]


@pytest.mark.parametrize("date_string", error_cases)
def test_should_error(date_string):
with pytest.raises(Exception):
hijri_parser.parse(date_string)

0 comments on commit 2cc596e

Please sign in to comment.