Use from_date to compute first last date.
This commit is contained in:
parent
e855d01812
commit
7041faa217
|
@ -297,7 +297,7 @@ class Location(metaclass=PoolMeta):
|
|||
first_state = history_states[0]
|
||||
else:
|
||||
return None
|
||||
last_date = first_state.date
|
||||
last_date = max(first_state.date, from_date)
|
||||
last_state = first_state.state
|
||||
for hstate in history_states:
|
||||
if last_state == state and last_state != hstate.state:
|
||||
|
|
|
@ -78,6 +78,9 @@ class LocationStateHistoryTestCase(ModuleTestCase):
|
|||
self.assertEqual(production.get_state_time_on(
|
||||
from_date + relativedelta(seconds=8),
|
||||
from_date + relativedelta(seconds=12)), timedelta(seconds=2))
|
||||
self.assertEqual(production.get_state_time_on(
|
||||
from_date + relativedelta(seconds=6),
|
||||
from_date + relativedelta(seconds=7)), timedelta(seconds=1))
|
||||
self.assertEqual(
|
||||
production.get_state_time_on(
|
||||
from_date + relativedelta(seconds=5),
|
||||
|
|
Loading…
Reference in New Issue