Skip to content

Commit

Permalink
[yang] remove mistakenly added parameter for 'get_module_name' (#2193)
Browse files Browse the repository at this point in the history
#### What I did
Revert parameter from function that was mistakenly added in #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()
  • Loading branch information
ayurkiv-nvda authored and judyjoseph committed Jun 13, 2022
1 parent 2b12a39 commit e2dd672
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/config_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def get_module_name(yang_module_str):
"""

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

Expand Down
8 changes: 8 additions & 0 deletions tests/config_mgmt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
config_mgmt_py_path = os.path.join(os.path.dirname(__file__), '..', 'config', 'config_mgmt.py')
config_mgmt = load_module_from_source('config_mgmt', config_mgmt_py_path)

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

class TestConfigMgmt(TestCase):
'''
Expand All @@ -22,6 +23,13 @@ def setUp(self):
config_mgmt.DEFAULT_CONFIG_DB_JSON_FILE = "portBreakOutConfigDb.json"
return

def test_config_get_module_check(self):
curConfig = deepcopy(configDbJson)
self.writeJson(curConfig, config_mgmt.CONFIG_DB_JSON_FILE)
cm = config_mgmt.ConfigMgmt(source=config_mgmt.CONFIG_DB_JSON_FILE)
assert cm.get_module_name(model) == "test_name"
return

def test_config_validation(self):
curConfig = deepcopy(configDbJson)
self.writeJson(curConfig, config_mgmt.CONFIG_DB_JSON_FILE)
Expand Down

0 comments on commit e2dd672

Please sign in to comment.