Skip to content

Commit

Permalink
fixing some tests....
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Aug 14, 2023
1 parent 3b69894 commit fc528eb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from os.path import dirname, join, exists, isfile
from threading import Event
from unittest.mock import Mock
from unittest.mock import call

import lingua_franca
import pytest
Expand All @@ -40,6 +39,7 @@
from ovos_config.config import Configuration
from ovos_utils.events import EventSchedulerInterface
from ovos_utils.messagebus import FakeBus
from ovos_utils.time import get_config_tz
from ovos_utils.time import now_local
from ovos_workshop.skill_launcher import SkillLoader

Expand Down Expand Up @@ -1677,7 +1677,7 @@ def test_parse_alert_time_from_message_alarm(self):
_get_message_from_file("alarm_every_monday_thursday.json")
alert_time = parse_alert_time_from_message(multi_day_repeat)
self.assertIsInstance(alert_time, dt.datetime)
self.assertEqual(alert_time.tzinfo, dt.timezone.utc)
self.assertEqual(alert_time.tzinfo, get_config_tz())
self.assertEqual(alert_time.time(), dt.time(hour=9))

def test_parse_alert_time_from_message_timer(self):
Expand Down
12 changes: 6 additions & 6 deletions util/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from typing import Set, Optional, Union
from ovos_utils.log import LOG
from ovos_utils.time import now_local
from . import AlertType, AlertPriority, Weekdays


Expand Down Expand Up @@ -97,8 +98,8 @@ def is_expired(self) -> bool:
"""
expiration = \
datetime.datetime.fromisoformat(self._data["next_expiration_time"])
now = datetime.datetime.now(expiration.tzinfo)
return now >= expiration

return now_local() >= expiration

@property
def time_to_expiration(self) -> datetime.timedelta:
Expand All @@ -111,7 +112,7 @@ def time_to_expiration(self) -> datetime.timedelta:
# return None
expiration = \
datetime.datetime.fromisoformat(self._data["next_expiration_time"])
now = datetime.datetime.now(expiration.tzinfo)
now = now_local()
now.replace(microsecond=0)
return expiration - now

Expand Down Expand Up @@ -145,9 +146,8 @@ def _get_next_expiration_time(self) -> Optional[datetime.datetime]:
"""
Determine the next time this alert will expire and update Alert data
"""
expiration = datetime.datetime.fromisoformat(
self._data["next_expiration_time"])
now = datetime.datetime.now(expiration.tzinfo)
expiration = datetime.datetime.fromisoformat(self._data["next_expiration_time"])
now = now_local()

# Alert hasn't expired since last update
if now < expiration:
Expand Down
4 changes: 2 additions & 2 deletions util/alert_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from ovos_bus_client import Message
from ovos_utils.events import EventSchedulerInterface
from ovos_utils.log import LOG
from ovos_utils.time import to_system as to_system_time
from ovos_utils.time import to_local

from . import AlertState, AlertType
from .alert import Alert
Expand Down Expand Up @@ -318,7 +318,7 @@ def _schedule_alert_expiration(self, alrt: Alert, ident: str):
context = data.get("context")
LOG.debug(f"Scheduling alert: {ident}")
self._scheduler.schedule_event(self._handle_alert_expiration,
to_system_time(expire_time),
to_local(expire_time),
data, ident, context=context)

def _handle_alert_expiration(self, message: Message):
Expand Down

0 comments on commit fc528eb

Please sign in to comment.