H6RFGRA6W24KDK4GEC4S26RBUQELZJJDRKPEZCD5W6WU3UBPLJJQC
OKPCYKFRUVA3KXT6I722VW4EN3QNJWDOM34FKCSW36PZCNPAUDQQC
UGT3GABDAFKEMPYA2G2ATTGHAITHWLOMCVSI5NLGXZNZ7BDFKONQC
VRJ6XA2ZRV5MP6UVYCFFWOVHXFFVOMNXZP4LZ5EYYPYKSDHJYCGAC
GIKW7G7ZCEUPTGDPUV236VJCPM7UGNKI6LI2T5KMIUWVNB4PICQQC
UILSLVIAB4X2JHH57MLWDO4BFD665BPR2ISHEX35VFMVGP7QPGYAC
import pytest
from beats.exceptions import InconsistentEndTime
pass
from beats.models import TimeLog # Fix for freezegun to work log = TimeLog(start=datetime.fromisoformat("2021-01-11T01:00:00")) with pytest.raises(InconsistentEndTime): log.stop_timer(datetime.fromisoformat("2020-01-11T02:00:00"))
from beats.models import TimeLog # Fix for freezegun to work
log = TimeLog(start=datetime.fromisoformat("2021-01-11T01:00:00"))
with pytest.raises(InconsistentEndTime):
log.stop_timer(datetime.fromisoformat("2020-01-11T02:00:00"))
from .exceptions import LogIsStopped
from .exceptions import LogIsStopped, InconsistentEndTime
def stop_timer(self, time):
def stop_timer(self, time: datetime): """ Closes the log with the provided time. Validates the closing time is consistent with the start time -> comes after it. """
def stop_timer(self, time: datetime):
"""
Closes the log with the provided time.
Validates the closing time is consistent with the start time -> comes after it.
if time < self.start: # less than symbol "<" means "before" when comparing times raise InconsistentEndTime
if time < self.start: # less than symbol "<" means "before" when comparing times
raise InconsistentEndTime
class InconsistentEndTime(Exception): message = "End time must come after start time"
class InconsistentEndTime(Exception):
message = "End time must come after start time"