From 493de16d477f0745c53fe0fc5a1ed64eb2daa847 Mon Sep 17 00:00:00 2001 From: NEC-Vishal <105697861+NEC-Vishal@users.noreply.github.com> Date: Mon, 28 Nov 2022 10:20:01 +0530 Subject: [PATCH 1/3] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b41d37df..4b97bcc1 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -24,6 +24,7 @@ - Replaced entity with getter (#652) - Resolved TODO in Dockerfile (#680) - Resolved TODO at src/reporter/tests/test_timescale_types.py (#667) +- Resolved TODO at src/wq/ql/flask_utils.py (#707) ### Bug fixes From 38154f16d4043213a254b6e4ca8c9e312dda0d99 Mon Sep 17 00:00:00 2001 From: NEC-Vishal Date: Mon, 19 Dec 2022 05:16:35 +0000 Subject: [PATCH 2/3] factor out in reporter/tests/test_timescale_types.py --- src/reporter/tests/test_timescale_types.py | 40 ++++------------------ 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/src/reporter/tests/test_timescale_types.py b/src/reporter/tests/test_timescale_types.py index 7dd88153..6e09e515 100644 --- a/src/reporter/tests/test_timescale_types.py +++ b/src/reporter/tests/test_timescale_types.py @@ -109,40 +109,12 @@ def gen_entity(entity_id: int, # Similar to gen_entity in test_timescale_insert module in translators.tests. -def entity_name_value_pairs(entity: dict) -> dict: - """ - Transform an NGSI entity ``e`` into the format:: - - { - entityId: e[id] - attr1: [ e[attr1][value] ] - ... - attrN: [ e[attrN][value] ] - } - """ - eid = {'entityId': entity['id']} - - attr_names = {k for k in entity.keys()} - {'id', 'type'} - attrs = {k: [maybe_value(entity, k, 'value')] for k in attr_names} - - return merge_dicts(eid, attrs) - -# TODO: factor out? -# This function and the one below could come in handy when testing a number -# of scenarios where we first insert entities and then query them by ID. - +def entity_query_result_name_value_pairs(data: dict) -> dict: -def query_result_name_value_pairs(result: dict) -> dict: - """ - Extract the result set returned by the ``/v2/entities/{entityId}`` endpoint - using the same format as that of ``entity_name_value_pairs``. - """ - eid = {'entityId': maybe_value(result, 'entityId')} + eid = {'entityId': maybe_value(data, 'entityId')} - attrs_array = maybe_value(result, 'attributes') - attrs_array = attrs_array if attrs_array else [] - attrs = {maybe_value(a, 'attrName'): maybe_value(a, 'values') - for a in attrs_array} + attr_names = {k for k in data.keys()} - {'id', 'type'} + attrs = {k: [maybe_value(data, k, 'value')] for k in attr_names} return merge_dicts(eid, attrs) @@ -189,8 +161,8 @@ def test_entity_with_all_supported_types(): result_set = query_entity_by_id(e['id'], service) - actual = query_result_name_value_pairs(result_set) - expected = entity_name_value_pairs(e) + actual = entity_query_result_name_value_pairs(result_set) + expected = entity_query_result_name_value_pairs(e) assert actual == expected # TODO: probabilistic testing. From 3224da0c4a6240114fbbc6c9e98cb1943f1ab864 Mon Sep 17 00:00:00 2001 From: NEC-Vishal <105697861+NEC-Vishal@users.noreply.github.com> Date: Mon, 19 Dec 2022 10:49:44 +0530 Subject: [PATCH 3/3] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4b97bcc1..bd4121dd 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -25,6 +25,7 @@ - Resolved TODO in Dockerfile (#680) - Resolved TODO at src/reporter/tests/test_timescale_types.py (#667) - Resolved TODO at src/wq/ql/flask_utils.py (#707) +- factor out in src/reporter/tests/test_timescale_types.py (#710) ### Bug fixes