Skip to content

Commit

Permalink
Address coverage issues flagged by codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Dec 20, 2024
1 parent d9fd4ba commit 4372b23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
11 changes: 3 additions & 8 deletions src/undate/converters/edtf/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,19 @@ def year_unspecified(self, items):
return Tree(data="year", children=[value])

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

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

def date_level1(self, items):
return self.date(items)

def year(self, items):
# when the year is negative, there are two tokens
if len(items) > 1 and items[0] == "-":
# an anonymous token for the - and the integer year
year = items[1]
return Tree(data="year", children=[-year])

return Tree(data="year", children=[items[0]])
# year (including negative years) use default transformation

def year_fivedigitsplus(self, items):
# strip off the leading Y and convert to integer
Expand Down
14 changes: 13 additions & 1 deletion tests/test_converters/test_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

import pytest
from undate.converters.base import BaseDateConverter
from undate.converters.base import BaseDateConverter, BaseCalendarConverter


class TestBaseDateConverter:
Expand Down Expand Up @@ -62,3 +62,15 @@ class ISO8601DateFormat2(BaseDateConverter):
assert len(BaseDateConverter.available_converters()) != len(
BaseDateConverter.subclasses()
)


class TestBaseCalendarConverter:
def test_not_implemented(self):
with pytest.raises(NotImplementedError):
BaseCalendarConverter().min_month()
with pytest.raises(NotImplementedError):
BaseCalendarConverter().max_month(1900)
with pytest.raises(NotImplementedError):
BaseCalendarConverter().max_day(1900, 12)
with pytest.raises(NotImplementedError):
BaseCalendarConverter().to_gregorian(1900, 12, 31)

0 comments on commit 4372b23

Please sign in to comment.