From defad03762a6ffcc8a28eead85ef9ca7463f2fd6 Mon Sep 17 00:00:00 2001
From: Lluis Gifre <lluis.gifre@cttc.es>
Date: Tue, 2 Aug 2022 14:37:23 +0000
Subject: [PATCH] Device component:

- fixed parsing of custom rules in unitary tests
---
 src/device/tests/test_unitary_openconfig.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/device/tests/test_unitary_openconfig.py b/src/device/tests/test_unitary_openconfig.py
index 47bea7ef6..32fb5709a 100644
--- a/src/device/tests/test_unitary_openconfig.py
+++ b/src/device/tests/test_unitary_openconfig.py
@@ -88,8 +88,9 @@ def test_device_openconfig_add_correct(
 
     device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID))
     config_rules = [
-        (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value)
+        (ConfigActionEnum.Name(config_rule.action), config_rule.custom.resource_key, config_rule.custom.resource_value)
         for config_rule in device_data.device_config.config_rules
+        if config_rule.WhichOneof('config_rule') == 'custom'
     ]
     LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format(
         '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules])))
@@ -135,8 +136,9 @@ def test_device_openconfig_configure(
 
     device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID))
     config_rules = [
-        (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value)
+        (ConfigActionEnum.Name(config_rule.action), config_rule.custom.resource_key, config_rule.custom.resource_value)
         for config_rule in device_data.device_config.config_rules
+        if config_rule.WhichOneof('config_rule') == 'custom'
     ]
     LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format(
         '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules])))
@@ -276,7 +278,7 @@ def test_device_openconfig_deconfigure(
 
     device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID))
     config_rules = [
-        (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value)
+        (ConfigActionEnum.Name(config_rule.action), config_rule.custom.resource_key, config_rule.custom.resource_value)
         for config_rule in device_data.device_config.config_rules
         if config_rule.WhichOneof('config_rule') == 'custom'
     ]
-- 
GitLab