Skip to content

Commit 4372b23

Browse files
committed
Address coverage issues flagged by codecov
1 parent d9fd4ba commit 4372b23

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/undate/converters/edtf/transformer.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,19 @@ def year_unspecified(self, items):
5454
return Tree(data="year", children=[value])
5555

5656
def month_unspecified(self, items):
57+
# combine multiple parts into a single string
5758
value = "".join(self.get_values(items))
5859
return Tree(data="month", children=[value])
5960

6061
def day_unspecified(self, items):
62+
# combine multiple parts into a single string
6163
value = "".join(self.get_values(items))
6264
return Tree(data="day", children=[value])
6365

6466
def date_level1(self, items):
6567
return self.date(items)
6668

67-
def year(self, items):
68-
# when the year is negative, there are two tokens
69-
if len(items) > 1 and items[0] == "-":
70-
# an anonymous token for the - and the integer year
71-
year = items[1]
72-
return Tree(data="year", children=[-year])
73-
74-
return Tree(data="year", children=[items[0]])
69+
# year (including negative years) use default transformation
7570

7671
def year_fivedigitsplus(self, items):
7772
# strip off the leading Y and convert to integer

tests/test_converters/test_base.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22

33
import pytest
4-
from undate.converters.base import BaseDateConverter
4+
from undate.converters.base import BaseDateConverter, BaseCalendarConverter
55

66

77
class TestBaseDateConverter:
@@ -62,3 +62,15 @@ class ISO8601DateFormat2(BaseDateConverter):
6262
assert len(BaseDateConverter.available_converters()) != len(
6363
BaseDateConverter.subclasses()
6464
)
65+
66+
67+
class TestBaseCalendarConverter:
68+
def test_not_implemented(self):
69+
with pytest.raises(NotImplementedError):
70+
BaseCalendarConverter().min_month()
71+
with pytest.raises(NotImplementedError):
72+
BaseCalendarConverter().max_month(1900)
73+
with pytest.raises(NotImplementedError):
74+
BaseCalendarConverter().max_day(1900, 12)
75+
with pytest.raises(NotImplementedError):
76+
BaseCalendarConverter().to_gregorian(1900, 12, 31)

0 commit comments

Comments
 (0)