Skip to content

Commit

Permalink
Merge pull request #71 from jepler/fix-update-checking
Browse files Browse the repository at this point in the history
Fix update checking
  • Loading branch information
jepler authored Nov 19, 2023
2 parents 37828dc + bae19e3 commit 27f3323
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/wwvb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _maybe_warn_update(dt: datetime.date) -> None:
# If the date is less than 330 days after today, there should be (possibly)
# prospective available now.
today = datetime.date.today()
if dt < today + datetime.timedelta(days=330):
if _date(dt) < today + datetime.timedelta(days=330):
warnings.warn(
"Note: Running `updateiers` may provide better DUT1 and LS information"
)
Expand Down
4 changes: 2 additions & 2 deletions src/wwvb/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def parse_timespec( # pylint: disable=unused-argument
)
if len(value) == 1:
return dateutil.parser.parse(value[0])
if len(value) == 0: # pragma no cover
return datetime.datetime.utcnow()
if len(value) == 0:
return datetime.datetime.now(datetime.timezone.utc)
raise ValueError("Unexpected number of arguments")
except ValueError as e:
raise click.UsageError(f"Could not parse timespec: {e}") from e
Expand Down
9 changes: 9 additions & 0 deletions src/wwvb/testcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ def test_sextant(self) -> None:
"2021-12-6 3:40",
)

def test_now(self) -> None:
"""Test outputting timecodes for 'now'"""
self.assertModuleOutputStarts(
"WWVB timecode: year=",
"wwvb.gen",
"-m",
"1",
)

def test_decode(self) -> None:
"""Test the commandline decoder"""
self.assertModuleOutput(
Expand Down
3 changes: 2 additions & 1 deletion src/wwvb/testwwvb.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_cases(self) -> None:
channel = o[10:]
elif o.startswith("--style="):
style = o[8:]
else: # pragma: no cover
else:
raise ValueError(f"Unknown option {repr(o)}")
num_minutes = len(lines) - 2
if channel == "both":
Expand Down Expand Up @@ -335,6 +335,7 @@ def test_update(self) -> None:
"""Ensure that the 'maybe_warn_update' function is covered"""
with self.assertWarnsRegex(Warning, "updateiers"):
wwvb._maybe_warn_update(datetime.date(1970, 1, 1))
wwvb._maybe_warn_update(datetime.datetime(1970, 1, 1, 0, 0))

def test_undefined(self) -> None:
"""Ensure that the check for unset elements in am works"""
Expand Down

0 comments on commit 27f3323

Please sign in to comment.