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

CRUD delete on list with id ref as key bug fix #270

Merged
1 commit merged into from
Oct 12, 2016
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
17 changes: 17 additions & 0 deletions sdk/python/core/tests/test_sanity_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,23 @@ def test_delete_on_leaflist(self):
del runner_left.ytypes.built_in_t.llstring[3]
self.assertEqual(is_equal(runner_read, runner_create), True)

def test_delete_on_list_with_identitykey(self):
runner = ysanity.Runner()

a1 = ysanity.Runner.OneList.IdentityList()
a1.config.id = ysanity.ChildIdentityIdentity()
a1.id_ref = a1.config.id
runner.one_list.identity_list.extend([a1])

self.crud.create(self.ncc, runner)

empty_runner = ysanity.Runner()
runner_read = self.crud.read(self.ncc, empty_runner)
self.crud.delete(self.ncc, runner_read.one_list.identity_list)
runner_read = self.crud.read(self.ncc, empty_runner)

self.assertEqual(len(runner_read.one_list.identity_list), 0)

def test_delete_operation_on_container(self):
# create runner with a container
runner_create = ysanity.Runner()
Expand Down
6 changes: 6 additions & 0 deletions sdk/python/core/ydk/providers/_provider_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ def _match_list_key(self, root, entity):
key_value = getattr(entity, key.presentation_name)
if key.mtype == REFERENCE_ENUM_CLASS:
key_value = key_value.name.replace('_', '-').lower()
elif key.mtype == REFERENCE_IDENTITY_CLASS:
identity_inst = getattr(entity, key.presentation_name)
if _yang_ns._namespaces[key.module_name] == _yang_ns._namespaces[identity_inst._meta_info().module_name]:
key_value = identity_inst._meta_info().yang_name
else:
key_value = 'idx:%s' % identity_inst._meta_info().yang_name
key_value = str(key_value)
for ch in chs:
if key.name == ch.tag and key_value == ch.text:
Expand Down
22 changes: 22 additions & 0 deletions yang/ydktest/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,29 @@ module ydktest-sanity {
type string;
}
}

list identity-list {
description "one list data";
key "id-ref";
max-elements 5;
leaf id-ref {
description "leafref key";
type leafref {
path "../config/id";
}
}

container config {
leaf id{
description "base id id ref";
type identityref {
base base-identity;
}
}
}
}
}

}


Expand Down