Skip to content

Commit

Permalink
Merge pull request #7 from marciogranzotto/marcio/uploader-type
Browse files Browse the repository at this point in the history
Add missing uploader type
  • Loading branch information
marciogranzotto authored Dec 5, 2021
2 parents 64c2c8a + 6634bd3 commit a4a8776
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion py_nightscout/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SGV(BaseModel):
sgv (int): Glucose measurement value in mg/dl.
sgv_mmol (int): Glucose measurement value in mmol/L.
delta (float): Delta between current and previous value.
date (datetime): The time of the measurement
date (datetime): The time of the measurementpa
direction (string): One of ['DoubleUp', 'SingleUp', 'FortyFiveUp', 'Flat', 'FortyFiveDown', 'SingleDown', 'DoubleDown']
device (string): the source of the measurement. For example, 'share2', if pulled from Dexcom Share servers
"""
Expand Down Expand Up @@ -512,12 +512,14 @@ class UploaderBattery(BaseModel):
Attributes:
batteryVoltage (float): Battery Voltage.
battery (int): Battery percentage.
type (string): Uploader type.
"""

def __init__(self, **kwargs):
self.param_defaults = {
"batteryVoltage": None,
"battery": None,
"type": None,
}

for (param, default) in self.param_defaults.items():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="py_nightscout",
version="1.3.2",
version="1.3.3",
description="A library that provides a Python async interface to Nightscout",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
4 changes: 3 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def api_fixture() -> nightscout.Api:
'{"status":"ok","name":"nightscout","version":"13.0.1","serverTime":"2020-08-05T18:14:02.032Z","serverTimeEpoch":1596651242032,"apiEnabled":true,"careportalEnabled":true,"boluscalcEnabled":true,"settings":{"units":"mg/dl","timeFormat":12,"nightMode":false,"editMode":true,"showRawbg":"never","customTitle":"Nightscout","theme":"default","alarmUrgentHigh":true,"alarmUrgentHighMins":[30,60,90,120],"alarmHigh":true,"alarmHighMins":[30,60,90,120],"alarmLow":true,"alarmLowMins":[15,30,45,60],"alarmUrgentLow":true,"alarmUrgentLowMins":[15,30,45],"alarmUrgentMins":[30,60,90,120],"alarmWarnMins":[30,60,90,120],"alarmTimeagoWarn":true,"alarmTimeagoWarnMins":15,"alarmTimeagoUrgent":true,"alarmTimeagoUrgentMins":30,"alarmPumpBatteryLow":false,"language":"en","scaleY":"log","showPlugins":" delta direction upbat","showForecast":"ar2","focusHours":3,"heartbeat":60,"baseURL":"","authDefaultRoles":"readable","thresholds":{"bgHigh":260,"bgTargetTop":180,"bgTargetBottom":80,"bgLow":55},"insecureUseHttp":false,"secureHstsHeader":true,"secureHstsHeaderIncludeSubdomains":false,"secureHstsHeaderPreload":false,"secureCsp":false,"deNormalizeDates":false,"showClockDelta":false,"showClockLastTime":false,"DEFAULT_FEATURES":["bgnow","delta","direction","timeago","devicestatus","upbat","errorcodes","profile"],"alarmTypes":["predict"],"enable":["careportal","boluscalc","food","bwp","cage","sage","iage","iob","cob","basal","ar2","rawbg","pushover","bgi","pump","openaps","treatmentnotify","bgnow","delta","direction","timeago","devicestatus","upbat","errorcodes","profile","ar2"]},"extendedSettings":{"devicestatus":{"advanced":true}},"authorized":null}'
)
device_status_response = json.loads(
'[{"_id":"617dc8ef0c76ce0182e37978","device":"Tomato","uploader":{"battery":20},"created_at":"2021-10-30T22:36:31.901Z","utcOffset":-180,"mills":1635633391901},{"_id":"617dc8ef0c76ce0182e37977","device":"samsung SM-N986B","uploader":{"battery":69},"created_at":"2021-10-30T22:36:31.844Z","utcOffset":-180,"mills":1635633391844},{"_id":"617dc7c40c76ce0182e37976","device":"Tomato","uploader":{"battery":20},"created_at":"2021-10-30T22:31:32.252Z","utcOffset":-180,"mills":1635633092252},{"_id":"617dc7c40c76ce0182e37975","device":"samsung SM-N986B","uploader":{"battery":70},"created_at":"2021-10-30T22:31:32.198Z","utcOffset":-180,"mills":1635633092198},{"_id":"617dc6980c76ce0182e37974","device":"Tomato","uploader":{"battery":20},"created_at":"2021-10-30T22:26:32.128Z","utcOffset":-180,"mills":1635632792128},{"_id":"617dc6980c76ce0182e37973","device":"samsung SM-N986B","uploader":{"battery":70},"created_at":"2021-10-30T22:26:32.043Z","utcOffset":-180,"mills":1635632792043},{"_id":"617dc56c0c76ce0182e37972","device":"Tomato","uploader":{"battery":20},"created_at":"2021-10-30T22:21:32.955Z","utcOffset":-180,"mills":1635632492955},{"_id":"617dc56c0c76ce0182e37971","device":"samsung SM-N986B","uploader":{"battery":70},"created_at":"2021-10-30T22:21:32.902Z","utcOffset":-180,"mills":1635632492902},{"_id":"617dc43f0c76ce0182e37970","device":"Tomato","uploader":{"battery":20},"created_at":"2021-10-30T22:16:31.839Z","utcOffset":-180,"mills":1635632191839},{"_id":"617dc43f0c76ce0182e3796f","device":"samsung SM-N986B","uploader":{"battery":70},"created_at":"2021-10-30T22:16:31.784Z","utcOffset":-180,"mills":1635632191784}]'
'[{"_id":"617dc8ef0c76ce0182e37978","device":"Tomato","uploader":{"battery":20,"type":"BRIDGE"},"created_at":"2021-10-30T22:36:31.901Z","utcOffset":-180,"mills":1635633391901},{"_id":"617dc8ef0c76ce0182e37977","device":"samsung SM-N986B","uploader":{"battery":69,"type":"PHONE"},"created_at":"2021-10-30T22:36:31.844Z","utcOffset":-180,"mills":1635633391844},{"_id":"617dc7c40c76ce0182e37976","device":"Tomato","uploader":{"battery":20,"type":"BRIDGE"},"created_at":"2021-10-30T22:31:32.252Z","utcOffset":-180,"mills":1635633092252},{"_id":"617dc7c40c76ce0182e37975","device":"samsung SM-N986B","uploader":{"battery":70,"type":"PHONE"},"created_at":"2021-10-30T22:31:32.198Z","utcOffset":-180,"mills":1635633092198},{"_id":"617dc6980c76ce0182e37974","device":"Tomato","uploader":{"battery":20,"type":"BRIDGE"},"created_at":"2021-10-30T22:26:32.128Z","utcOffset":-180,"mills":1635632792128},{"_id":"617dc6980c76ce0182e37973","device":"samsung SM-N986B","uploader":{"battery":70,"type":"PHONE"},"created_at":"2021-10-30T22:26:32.043Z","utcOffset":-180,"mills":1635632792043},{"_id":"617dc56c0c76ce0182e37972","device":"Tomato","uploader":{"battery":20,"type":"BRIDGE"},"created_at":"2021-10-30T22:21:32.955Z","utcOffset":-180,"mills":1635632492955},{"_id":"617dc56c0c76ce0182e37971","device":"samsung SM-N986B","uploader":{"battery":70,"type":"PHONE"},"created_at":"2021-10-30T22:21:32.902Z","utcOffset":-180,"mills":1635632492902},{"_id":"617dc43f0c76ce0182e37970","device":"Tomato","uploader":{"battery":20,"type":"BRIDGE"},"created_at":"2021-10-30T22:16:31.839Z","utcOffset":-180,"mills":1635632191839},{"_id":"617dc43f0c76ce0182e3796f","device":"samsung SM-N986B","uploader":{"battery":70,"type":"PHONE"},"created_at":"2021-10-30T22:16:31.784Z","utcOffset":-180,"mills":1635632191784}]'
)


Expand Down Expand Up @@ -144,8 +144,10 @@ async def test_latest_devices_status(api: nightscout.Api):
== devices_status["Tomato"].created_at
)
assert 20 == devices_status["Tomato"].uploader.battery
assert "BRIDGE" == devices_status["Tomato"].uploader.type
assert (
dateutil.parser.parse("2021-10-30T22:36:31.844Z")
== devices_status["samsung SM-N986B"].created_at
)
assert 69 == devices_status["samsung SM-N986B"].uploader.battery
assert "PHONE" == devices_status["samsung SM-N986B"].uploader.type

0 comments on commit a4a8776

Please sign in to comment.