Skip to content

Commit 15670bf

Browse files
authored
[GCU] Adding unit-test where path and ref paths are under the same YANG container (sonic-net#2047)
#### What I did Did a debug session with Ping Mao and found this case is failing in her PR: sonic-net#9545 I think it is an interesting case and I added it explicitly to GCU. Adding unit-test where path and ref paths are under the same YANG container [sonic-loopback-interface.yang](https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/yang-models/sonic-loopback-interface.yang) has: ```yang container sonic-loopback-interface { container LOOPBACK_INTERFACE { list LOOPBACK_INTERFACE_LIST { ... leaf name{ type string; } ... list LOOPBACK_INTERFACE_IPPREFIX_LIST { leaf name{ ... type leafref { path "../../LOOPBACK_INTERFACE_LIST/name"; } } ... ``` #### How I did it Unit-test added #### How to verify it unit-test #### Previous command output (if the output of a command-line utility has changed) #### New command output (if the output of a command-line utility has changed)
1 parent 37225a4 commit 15670bf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/generic_config_updater/gu_common_test.py

+14
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,20 @@ def test_find_ref_paths__whole_config_path__returns_all_refs(self):
675675
# Assert
676676
self.assertEqual(expected, actual)
677677

678+
def test_find_ref_paths__path_and_ref_paths_are_under_same_yang_container__returns_ref_paths(self):
679+
# Arrange
680+
path = "/LOOPBACK_INTERFACE/Loopback0"
681+
expected = [
682+
self.path_addressing.create_path(["LOOPBACK_INTERFACE", "Loopback0|10.1.0.32/32"]),
683+
self.path_addressing.create_path(["LOOPBACK_INTERFACE", "Loopback0|1100:1::32/128"]),
684+
]
685+
686+
# Act
687+
actual = self.path_addressing.find_ref_paths(path, Files.CONFIG_DB_WITH_LOOPBACK_INTERFACES)
688+
689+
# Assert
690+
self.assertEqual(expected, actual)
691+
678692
def test_find_ref_paths__does_not_remove_tables_without_yang(self):
679693
# Arrange
680694
config = Files.CONFIG_DB_AS_JSON # This has a table without yang named 'TABLE_WITHOUT_YANG'

0 commit comments

Comments
 (0)