From 98ed0c6834ede2eec66234ee4c4bb6aa8153d433 Mon Sep 17 00:00:00 2001 From: Erick Daniszewski Date: Tue, 19 Jan 2021 15:27:16 -0500 Subject: [PATCH] feat: update grpc dependency to allow device info in reading responses --- requirements.txt | 2 +- setup.py | 2 +- synse_server/cmd/read.py | 1 + tests/unit/cmd/test_read.py | 11 +++++++++++ tests/unit/conftest.py | 3 +++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 77a60213..4f3aa865 100644 --- a/requirements.txt +++ b/requirements.txt @@ -38,7 +38,7 @@ shortuuid==1.0.1 # via synse_server (setup.py) six==1.15.0 # via google-auth, grpcio, kubernetes, protobuf, python-dateutil, structlog, websocket-client sniffio==1.1.0 # via httpx structlog==20.1.0 # via synse_server (setup.py) -synse-grpc==3.0.0 # via synse_server (setup.py) +synse-grpc==3.1.0 # via synse_server (setup.py) ujson==2.0.3 # via sanic urllib3==1.25.10 # via httpx, kubernetes, requests uvloop==0.14.0 # via sanic diff --git a/setup.py b/setup.py index 9e5c6410..30be32d8 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,7 @@ 'shortuuid', 'structlog>=20.1.0', 'websockets', - 'synse-grpc==3.0.0', + 'synse-grpc==3.1.0', ], zip_safe=False, classifiers=[ diff --git a/synse_server/cmd/read.py b/synse_server/cmd/read.py index e266a2e8..76635d47 100644 --- a/synse_server/cmd/read.py +++ b/synse_server/cmd/read.py @@ -42,6 +42,7 @@ def reading_to_dict(reading: api.V3Reading) -> Dict[str, Any]: 'timestamp': reading.timestamp, 'type': reading.type, 'device_type': reading.deviceType, + 'device_info': reading.deviceInfo, 'unit': unit, 'value': value, 'context': dict(reading.context), diff --git a/tests/unit/cmd/test_read.py b/tests/unit/cmd/test_read.py index 5bf4b592..0906738d 100644 --- a/tests/unit/cmd/test_read.py +++ b/tests/unit/cmd/test_read.py @@ -180,6 +180,7 @@ async def test_read_ok_no_tags(mocker, simple_plugin, temperature_reading, humid 'timestamp': '2019-04-22T13:30:00Z', 'type': 'temperature', 'device_type': 'temperature', + 'device_info': 'Example Temperature Device', 'unit': { 'name': 'celsius', 'symbol': 'C', @@ -194,6 +195,7 @@ async def test_read_ok_no_tags(mocker, simple_plugin, temperature_reading, humid 'timestamp': '2019-04-22T13:30:00Z', 'type': 'humidity', 'device_type': 'humidity', + 'device_info': 'Example Humidity Device', 'unit': { 'name': 'percent', 'symbol': '%', @@ -240,6 +242,7 @@ async def test_read_ok_tags_with_ns(mocker, simple_plugin, state_reading): 'timestamp': '2019-04-22T13:30:00Z', 'type': 'state', 'device_type': 'led', + 'device_info': 'Example LED Device', 'value': 'on', 'unit': None, 'context': {}, @@ -286,6 +289,7 @@ async def test_read_ok_tags_without_ns(mocker, simple_plugin, state_reading): 'timestamp': '2019-04-22T13:30:00Z', 'type': 'state', 'device_type': 'led', + 'device_info': 'Example LED Device', 'value': 'on', 'unit': None, 'context': {}, @@ -332,6 +336,7 @@ async def test_read_ok_single_tag_group_without_ns(mocker, simple_plugin, state_ 'timestamp': '2019-04-22T13:30:00Z', 'type': 'state', 'device_type': 'led', + 'device_info': 'Example LED Device', 'value': 'on', 'unit': None, 'context': {}, @@ -378,6 +383,7 @@ async def test_read_ok_single_tag_group_without_ns_with_plugin( 'timestamp': '2019-04-22T13:30:00Z', 'type': 'state', 'device_type': 'led', + 'device_info': 'Example LED Device', 'value': 'on', 'unit': None, 'context': {}, @@ -489,6 +495,7 @@ async def test_read_device_ok(mocker, simple_plugin, temperature_reading): 'timestamp': '2019-04-22T13:30:00Z', 'type': 'temperature', 'device_type': 'temperature', + 'device_info': 'Example Temperature Device', 'unit': { 'name': 'celsius', 'symbol': 'C', @@ -578,6 +585,7 @@ def patchreadcache(*args, **kwargs): 'timestamp': '2019-04-22T13:30:00Z', 'type': 'humidity', 'device_type': 'humidity', + 'device_info': 'Example Humidity Device', 'unit': { 'name': 'percent', 'symbol': '%', @@ -624,6 +632,7 @@ def test_reading_to_dict_1(temperature_reading): 'timestamp': '2019-04-22T13:30:00Z', 'type': 'temperature', 'device_type': 'temperature', + 'device_info': 'Example Temperature Device', 'unit': { 'name': 'celsius', 'symbol': 'C', @@ -643,6 +652,7 @@ def test_reading_to_dict_2(humidity_reading): 'timestamp': '2019-04-22T13:30:00Z', 'type': 'humidity', 'device_type': 'humidity', + 'device_info': 'Example Humidity Device', 'unit': { 'name': 'percent', 'symbol': '%', @@ -660,6 +670,7 @@ def test_reading_to_dict_3(state_reading): 'timestamp': '2019-04-22T13:30:00Z', 'type': 'state', 'device_type': 'led', + 'device_info': 'Example LED Device', 'value': 'on', 'unit': None, 'context': {}, diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 3c84860c..34bdab32 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -170,6 +170,7 @@ def temperature_reading(): timestamp='2019-04-22T13:30:00Z', type='temperature', deviceType='temperature', + deviceInfo='Example Temperature Device', context={'zone': '1'}, unit=api.V3OutputUnit( name='celsius', @@ -188,6 +189,7 @@ def humidity_reading(): timestamp='2019-04-22T13:30:00Z', type='humidity', deviceType='humidity', + deviceInfo='Example Humidity Device', unit=api.V3OutputUnit( name='percent', symbol='%', @@ -205,6 +207,7 @@ def state_reading(): timestamp='2019-04-22T13:30:00Z', type='state', deviceType='led', + deviceInfo='Example LED Device', string_value='on', )