Skip to content

Commit

Permalink
add comments and an extra testcase
Browse files Browse the repository at this point in the history
Signed-off-by: Swapnil Wagh <waghswapnil@gmail.com>
  • Loading branch information
waghswapnil committed Feb 1, 2017
1 parent dea5c7a commit 386a159
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion imcsdk/imccoreutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def extract_molist_from_method_response(method_response,


def filter_molist_on_class_id(mo_list, class_id=None):
if class_id is None:
if not class_id:
return mo_list

out_list = [mo for mo in mo_list if mo._class_id.lower() == class_id.lower()]
Expand Down
5 changes: 5 additions & 0 deletions imcsdk/imchandle.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ def query_children(self, in_mo=None, in_dn=None, class_id=None,
parent_dn = in_dn

meta_class_id = None
# Setting the default class-id to None
# When hierarchy and class-id are passed together to Cisco IMC,
# an empty response is received.
# Hence, passing the class-id only when hierarchy is not set
# When both hierarchy and class-id are set, do local filtering for class-id
if class_id and not hierarchy:
meta_class_id = imccoreutils.find_class_id_in_mo_meta_ignore_case(
class_id)
Expand Down
5 changes: 5 additions & 0 deletions tests/common/test_query_children.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def test_hierarchy():
assert_equal(len(mos) > 30, True)


def test_hierarchy_with_empty_class_id():
mos = handle.query_children(in_dn="sys/svc-ext", hierarchy=True, class_id="")
assert_equal(len(mos) > 30, True)


def test_hierarchy_with_class_id():
mos = handle.query_children(in_dn="sys/svc-ext", class_id="commSnmpUser",
hierarchy=True)
Expand Down

0 comments on commit 386a159

Please sign in to comment.