Skip to content

Commit bb185d5

Browse files
authored
[yang] remove mistakenly added parameter for 'get_module_name' (#2193)
#### What I did Revert parameter from function that was mistakenly added in sonic-net/sonic-utilities#2118 We don't need to pass 'sonic_yang_options' to static function get_module_name() #### How I did it remove 'sonic_yang_options' from SonicYang object creation in get_module_name()
1 parent 2cccf26 commit bb185d5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

config/config_mgmt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def get_module_name(yang_module_str):
281281
"""
282282

283283
# Instantiate new context since parse_module_mem() loads the module into context.
284-
sy = sonic_yang.SonicYang(YANG_DIR, sonic_yang_options=self.sonicYangOptions)
284+
sy = sonic_yang.SonicYang(YANG_DIR)
285285
module = sy.ctx.parse_module_mem(yang_module_str, ly.LYS_IN_YANG)
286286
return module.name()
287287

tests/config_mgmt_test.py

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
config_mgmt_py_path = os.path.join(os.path.dirname(__file__), '..', 'config', 'config_mgmt.py')
1212
config_mgmt = load_module_from_source('config_mgmt', config_mgmt_py_path)
1313

14+
model = "module test_name {namespace urn:test_urn; prefix test_prefix;}"
1415

1516
class TestConfigMgmt(TestCase):
1617
'''
@@ -22,6 +23,13 @@ def setUp(self):
2223
config_mgmt.DEFAULT_CONFIG_DB_JSON_FILE = "portBreakOutConfigDb.json"
2324
return
2425

26+
def test_config_get_module_check(self):
27+
curConfig = deepcopy(configDbJson)
28+
self.writeJson(curConfig, config_mgmt.CONFIG_DB_JSON_FILE)
29+
cm = config_mgmt.ConfigMgmt(source=config_mgmt.CONFIG_DB_JSON_FILE)
30+
assert cm.get_module_name(model) == "test_name"
31+
return
32+
2533
def test_config_validation(self):
2634
curConfig = deepcopy(configDbJson)
2735
self.writeJson(curConfig, config_mgmt.CONFIG_DB_JSON_FILE)

0 commit comments

Comments
 (0)