mirror of
https://github.com/bckelley/tconnectsync.git
synced 2026-08-24 03:34:12 -05:00
timestamp override in tests
This commit is contained in:
@@ -6,6 +6,7 @@ from ..secret import TIMEZONE_NAME
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
EVENT_LEN = 26
|
EVENT_LEN = 26
|
||||||
|
# Big endian
|
||||||
UINT16 = '>H'
|
UINT16 = '>H'
|
||||||
UINT32 = '>I'
|
UINT32 = '>I'
|
||||||
TANDEM_EPOCH = 1199145600
|
TANDEM_EPOCH = 1199145600
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import arrow
|
|||||||
|
|
||||||
from ...features import DEFAULT_FEATURES
|
from ...features import DEFAULT_FEATURES
|
||||||
from ... import features
|
from ... import features
|
||||||
from ...secret import TIMEZONE_NAME
|
from ... import secret
|
||||||
from ...eventparser.generic import Events, decode_raw_events, EVENT_LEN
|
from ...eventparser.generic import Events, decode_raw_events, EVENT_LEN
|
||||||
from ...eventparser.utils import bitmask_to_list
|
from ...eventparser.utils import bitmask_to_list
|
||||||
from ...eventparser.raw_event import TANDEM_EPOCH
|
from ...eventparser.raw_event import TANDEM_EPOCH
|
||||||
@@ -17,12 +17,13 @@ from ...parser.nightscout import (
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class ProcessCGMReading:
|
class ProcessCGMReading:
|
||||||
def __init__(self, tconnect, nightscout, tconnect_device_id, pretend, features=DEFAULT_FEATURES):
|
def __init__(self, tconnect, nightscout, tconnect_device_id, pretend, features=DEFAULT_FEATURES, timezone=None):
|
||||||
self.tconnect = tconnect
|
self.tconnect = tconnect
|
||||||
self.nightscout = nightscout
|
self.nightscout = nightscout
|
||||||
self.tconnect_device_id = tconnect_device_id
|
self.tconnect_device_id = tconnect_device_id
|
||||||
self.pretend = pretend
|
self.pretend = pretend
|
||||||
self.features = features
|
self.features = features
|
||||||
|
self.timezone = timezone or secret.TIMEZONE_NAME
|
||||||
|
|
||||||
def enabled(self):
|
def enabled(self):
|
||||||
return features.CGM in self.features
|
return features.CGM in self.features
|
||||||
@@ -67,7 +68,7 @@ class ProcessCGMReading:
|
|||||||
def timestamp_for(self, event):
|
def timestamp_for(self, event):
|
||||||
# For backfills the time the event was added to the pump's event store
|
# For backfills the time the event was added to the pump's event store
|
||||||
# might not be the time it actually occurred, so we use the egvTimestamp
|
# might not be the time it actually occurred, so we use the egvTimestamp
|
||||||
return arrow.get(TANDEM_EPOCH + event.egvTimestamp, tzinfo='UTC').replace(tzinfo=TIMEZONE_NAME)
|
return arrow.get(TANDEM_EPOCH + event.egvTimestamp, tzinfo='UTC').replace(tzinfo=self.timezone)
|
||||||
|
|
||||||
def to_nsentry(self, event):
|
def to_nsentry(self, event):
|
||||||
return NightscoutEntry.entry(
|
return NightscoutEntry.entry(
|
||||||
|
|||||||
Reference in New Issue
Block a user