Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[yang] remove mistakenly added parameter for 'get_module_name' #2193

Merged
merged 2 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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