From c2a789ad113490eceae631d7e735358eebfc5055 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Sun, 29 Jan 2023 09:07:56 +0000
Subject: [PATCH] Device component:

- corrected parameters for composing config rules considering previous values
- corrected unitary test for deconfigure
---
 src/device/service/Tools.py               | 1 +
 src/device/tests/test_unitary_emulated.py | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/device/service/Tools.py b/src/device/service/Tools.py
index 28b5391a7..970a35e37 100644
--- a/src/device/service/Tools.py
+++ b/src/device/service/Tools.py
@@ -119,6 +119,7 @@ def _raw_config_rules_to_grpc(
             continue
 
         resource_value = json.loads(resource_value) if isinstance(resource_value, str) else resource_value
+        resource_value = {field_name : (field_value, False) for field_name,field_value in resource_value.items()}
         update_config_rule_custom(device_config.config_rules, resource_key, resource_value, new_action=config_action)
 
     return errors
diff --git a/src/device/tests/test_unitary_emulated.py b/src/device/tests/test_unitary_emulated.py
index 1af1ad861..0e5f8e22d 100644
--- a/src/device/tests/test_unitary_emulated.py
+++ b/src/device/tests/test_unitary_emulated.py
@@ -379,7 +379,11 @@ def test_device_emulated_deconfigure(
     for config_rule in config_rules:
         assert config_rule.WhichOneof('config_rule') == 'custom'
         if config_rule.custom.resource_key.startswith('/endpoints/endpoint'): continue
-        config_rule_value = json.loads(config_rule.custom.resource_value)
+        if config_rule.custom.resource_key.startswith('_connect/'): continue
+        try:
+            config_rule_value = json.loads(config_rule.custom.resource_value)
+        except: # pylint: disable=bare-except
+            config_rule_value = config_rule.custom.resource_value
         if isinstance(config_rule_value, str) and config_rule_value.startswith('do_sampling (trigger:'): continue
         clean_config_rules.append(config_rule)
     LOGGER.info('clean_config_rules = {:s}'.format(str(clean_config_rules)))
-- 
GitLab