diff --git a/sdk/cpp/tests/test_executor_service.cpp b/sdk/cpp/tests/test_executor_service.cpp index 811d4e3d1..b81524c50 100644 --- a/sdk/cpp/tests/test_executor_service.cpp +++ b/sdk/cpp/tests/test_executor_service.cpp @@ -199,8 +199,8 @@ TEST_CASE("es_edit_config_rpc") // runner and filter auto runner = make_shared(); - runner->ydktest_sanity_one->number = 1; - runner->ydktest_sanity_one->name = "runner:one:name"; + runner->one->number = 1; + runner->one->name = "runner:one:name"; std::string runner_xml = codec_service.encode(codec_provider, *runner, true); auto filter = make_unique(); diff --git a/sdk/cpp/tests/test_sanity_codec.cpp b/sdk/cpp/tests/test_sanity_codec.cpp index b6632f188..4bf0d77a2 100644 --- a/sdk/cpp/tests/test_sanity_codec.cpp +++ b/sdk/cpp/tests/test_sanity_codec.cpp @@ -392,9 +392,9 @@ TEST_CASE("encode_decode") ydktest_sanity::Runner * entity_ptr = dynamic_cast(redecode.get()); auto runner = std::make_unique(); - runner->ydktest_sanity_one->name = "test"; + runner->one->name = "test"; - CHECK(entity_ptr->ydktest_sanity_one->name == runner->ydktest_sanity_one->name); + CHECK(entity_ptr->one->name == runner->one->name); } TEST_CASE("multiple_bundles_codec") diff --git a/sdk/cpp/tests/test_sanity_levels.cpp b/sdk/cpp/tests/test_sanity_levels.cpp index 02494f010..6489bbbc5 100644 --- a/sdk/cpp/tests/test_sanity_levels.cpp +++ b/sdk/cpp/tests/test_sanity_levels.cpp @@ -42,38 +42,38 @@ TEST_CASE("one_level_pos") bool reply = crud.delete_(provider, *r_1); REQUIRE(reply); - auto ydktest_sanity_one = make_unique(); - ydktest_sanity_one->number = 1; - ydktest_sanity_one->name = "1.2.3.4"; - reply = crud.create(provider, *ydktest_sanity_one); + auto one = make_unique(); + one->number = 1; + one->name = "1.2.3.4"; + reply = crud.create(provider, *one); REQUIRE(reply); auto filter = make_unique(); - auto sanity_one_filter = filter->ydktest_sanity_one; + auto sanity_one_filter = filter->one; auto r_2 = crud.read(provider, *sanity_one_filter); REQUIRE(r_2!=nullptr); - auto * r_2_ptr = dynamic_cast(r_2.get()); + auto * r_2_ptr = dynamic_cast(r_2.get()); REQUIRE(r_2_ptr!=nullptr); - REQUIRE(ydktest_sanity_one->number == r_2_ptr->number); - REQUIRE(ydktest_sanity_one->name == r_2_ptr->name); + REQUIRE(one->number == r_2_ptr->number); + REQUIRE(one->name == r_2_ptr->name); //UPDATE - ydktest_sanity_one->number = 10; - ydktest_sanity_one->name = "runner/one/name"; - reply = crud.update(provider, *ydktest_sanity_one); + one->number = 10; + one->name = "runner/one/name"; + reply = crud.update(provider, *one); REQUIRE(reply); r_2 = crud.read(provider, *sanity_one_filter); REQUIRE(r_2!=nullptr); - r_2_ptr = dynamic_cast(r_2.get()); + r_2_ptr = dynamic_cast(r_2.get()); REQUIRE(r_2_ptr!=nullptr); - REQUIRE(ydktest_sanity_one->number == r_2_ptr->number); - REQUIRE(ydktest_sanity_one->name == r_2_ptr->name); + REQUIRE(one->number == r_2_ptr->number); + REQUIRE(one->name == r_2_ptr->name); // DELETE - reply = crud.delete_(provider, *ydktest_sanity_one); + reply = crud.delete_(provider, *one); REQUIRE(reply); } @@ -527,7 +527,7 @@ TEST_CASE("test_leafref_pos") REQUIRE(reply); //CREATE - r_1->ydktest_sanity_one->name = "1.2.3.4"; + r_1->one->name = "1.2.3.4"; r_1->two->sub1->number = 21; r_1->three->sub1->sub2->number = 311; auto e_1 = make_shared(); @@ -567,8 +567,8 @@ TEST_CASE("test_leafref_pos") auto r_filter = make_unique(); auto r_read = crud.read(provider, *r_filter); ydktest_sanity::Runner* r_2 = dynamic_cast(r_read.get()); - REQUIRE(r_1->ydktest_sanity_one->name == r_2->ydktest_sanity_one->name); - REQUIRE(r_1->ydktest_sanity_one->number == r_2->ydktest_sanity_one->number); + REQUIRE(r_1->one->name == r_2->one->name); + REQUIRE(r_1->one->number == r_2->one->number); auto ldata0 = dynamic_cast (r_2->inbtw_list->ldata[0].get()); auto ldata1 = dynamic_cast (r_2->inbtw_list->ldata[1].get()); @@ -593,8 +593,8 @@ TEST_CASE("aug_one_pos") REQUIRE(reply); //CREATE - r_1->ydktest_sanity_one->one_aug->number = 1; - r_1->ydktest_sanity_one->one_aug->name = "one"; + r_1->one->one_aug->number = 1; + r_1->one->one_aug->name = "one"; reply = crud.create(provider, *r_1); REQUIRE(reply); @@ -603,12 +603,12 @@ TEST_CASE("aug_one_pos") auto r_read = crud.read(provider, *r_filter); REQUIRE(r_read!=nullptr); ydktest_sanity::Runner* r_2 = dynamic_cast(r_read.get()); - REQUIRE(r_1->ydktest_sanity_one->one_aug->number == r_2->ydktest_sanity_one->one_aug->number); - REQUIRE(r_1->ydktest_sanity_one->one_aug->name == r_2->ydktest_sanity_one->one_aug->name); + REQUIRE(r_1->one->one_aug->number == r_2->one->one_aug->number); + REQUIRE(r_1->one->one_aug->name == r_2->one->one_aug->name); //UPDATE - r_1->ydktest_sanity_one->one_aug->number = 10; - r_1->ydktest_sanity_one->one_aug->name = "onenone"; + r_1->one->one_aug->number = 10; + r_1->one->one_aug->name = "onenone"; reply = crud.update(provider, *r_1); REQUIRE(reply); } @@ -683,7 +683,7 @@ TEST_CASE("aug_leaf") REQUIRE(reply); //CREATE - r_1->ydktest_sanity_one->augmented_leaf = "test"; + r_1->one->augmented_leaf = "test"; reply = crud.create(provider, *r_1); REQUIRE(reply); @@ -692,7 +692,7 @@ TEST_CASE("aug_leaf") auto r_read = crud.read(provider, *r_filter); REQUIRE(r_read != nullptr); ydktest_sanity::Runner* r_2 = dynamic_cast(r_read.get()); - REQUIRE(r_2->ydktest_sanity_one->augmented_leaf==r_1->ydktest_sanity_one->augmented_leaf); + REQUIRE(r_2->one->augmented_leaf==r_1->one->augmented_leaf); } TEST_CASE("oc_pattern") diff --git a/sdk/go/core/tests/levels_test.go b/sdk/go/core/tests/levels_test.go index 1eface2fd..4c20c09a0 100644 --- a/sdk/go/core/tests/levels_test.go +++ b/sdk/go/core/tests/levels_test.go @@ -40,16 +40,38 @@ func (suite *SanityLevelsTestSuite) TearDownSuite() { func (suite *SanityLevelsTestSuite) TestOneLevelPos() { // READ runner := ysanity.Runner{} - runner.YdktestSanityOne.Number = 1 - runner.YdktestSanityOne.Name = "runner:one:name" + runner.One.Number = 1 + runner.One.Name = "runner:one:name" suite.CRUD.Create(&suite.Provider, &runner) runnerRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{}) suite.Equal(types.EntityEqual(&runner, runnerRead), true) // UPDATE runner = ysanity.Runner{} - runner.YdktestSanityOne.Number = 10 - runner.YdktestSanityOne.Name = "runner/one/name" + runner.One.Number = 10 + runner.One.Name = "runner/one/name" + suite.CRUD.Update(&suite.Provider, &runner) + runnerRead = suite.CRUD.Read(&suite.Provider, &ysanity.Runner{}) + suite.Equal(types.EntityEqual(&runner, runnerRead), true) + + // // DELETE + runner = ysanity.Runner{} + suite.CRUD.Delete(&suite.Provider, &runner) + entity := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{}) + suite.Nil(entity) +} + +func (suite *SanityLevelsTestSuite) TestOneLevelAugPos() { + // READ + runner := ysanity.Runner{} + runner.YdktestSanityAugmOne.TwinNumber = 1000 + suite.CRUD.Create(&suite.Provider, &runner) + runnerRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{}) + suite.Equal(types.EntityEqual(&runner, runnerRead), true) + + // UPDATE + runner = ysanity.Runner{} + runner.YdktestSanityAugmOne.TwinNumber = 100 suite.CRUD.Update(&suite.Provider, &runner) runnerRead = suite.CRUD.Read(&suite.Provider, &ysanity.Runner{}) suite.Equal(types.EntityEqual(&runner, runnerRead), true) @@ -331,13 +353,13 @@ func (suite *SanityLevelsTestSuite) TestLeafrefSimplePos() { } func (suite *SanityLevelsTestSuite) TestAugOnePos() { - oneAug := ysanity.Runner_YdktestSanityOne_OneAug{} + oneAug := ysanity.Runner_One{} oneAug.Number = 1 oneAug.Name = "runner:one:one_aug" suite.CRUD.Create(&suite.Provider, &oneAug) - oneRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner_YdktestSanityOne_OneAug{}) + oneRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner_One{}) suite.Equal(types.EntityEqual(&oneAug, oneRead), true) } diff --git a/sdk/go/core/tests/service_codec_test.go b/sdk/go/core/tests/service_codec_test.go index c14e54bab..bf3f0d5a7 100644 --- a/sdk/go/core/tests/service_codec_test.go +++ b/sdk/go/core/tests/service_codec_test.go @@ -474,13 +474,13 @@ func (suite *CodecTestSuite) TestXMLEncodeDecodeMultiple() { func (suite *CodecTestSuite) TestPassiveInterfaceCodec() { runner := ysanity.Runner{} - ospf := ysanity.Runner_YdktestSanityOne_Ospf{} + ospf := ysanity.Runner_One_Ospf{} ospf.Id = 22 ospf.PassiveInterface.Interface = "xyz" - test := ysanity.Runner_YdktestSanityOne_Ospf_Test{} + test := ysanity.Runner_One_Ospf_Test{} test.Name = "abc" ospf.Test = append(ospf.Test, &test) - runner.YdktestSanityOne.Ospf = append(runner.YdktestSanityOne.Ospf, &ospf) + runner.One.Ospf = append(runner.One.Ospf, &ospf) suite.Provider.Encoding = encoding.XML payload := suite.Codec.Encode(&suite.Provider, &runner) suite.Equal(payload, diff --git a/sdk/go/core/tests/service_crud_test.go b/sdk/go/core/tests/service_crud_test.go index 98b2386c9..51e852354 100644 --- a/sdk/go/core/tests/service_crud_test.go +++ b/sdk/go/core/tests/service_crud_test.go @@ -105,13 +105,13 @@ func (suite *CrudTestSuite) BeforeTest(suiteName, testName string) { func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() { runnerCreate := ysanity.Runner{} - runnerCreate.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name" + runnerCreate.One.Name = "runner.YdktestSanityOne.Name" runnerCreate.Two.Name = "runner.Two.Name" suite.CRUD.Create(&suite.Provider, &runnerCreate) // Use YFilter Delete and CRUD update to remove leaf runnerUpdate := ysanity.Runner{} - runnerUpdate.YdktestSanityOne.Name = yfilter.Delete + runnerUpdate.One.Name = yfilter.Delete suite.CRUD.Update(&suite.Provider, &runnerUpdate) entityRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{}) @@ -124,7 +124,7 @@ func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() { // TODO: leaf-list encoding error // func (suite *CrudTestSuite) TestDeleteOnLeafListSlice() { // runnerCreate := ysanity.Runner{} -// runnerCreate.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name" +// runnerCreate.One.Name = "runner.YdktestSanityOne.Name" // // TODO: leaf-list encoding error // runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "1") // runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "2") @@ -142,7 +142,7 @@ func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() { // entityRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{}) // runnerCmp := ysanity.Runner{} -// runnerCmp.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name" +// runnerCmp.One.Name = "runner.One.Name" // runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "2") // runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "4") // runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "5") @@ -152,7 +152,7 @@ func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() { // TODO: delete leaf from leaf-list // func (suite *CrudTestSuite) TestDeleteOnLeafList() { // runnerCreate := ysanity.Runner{} -// runnerCreate.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name" +// runnerCreate.One.Name = "runner.YdktestSanityOne.Name" // runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "0") // runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "1") // runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "2") @@ -170,7 +170,7 @@ func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() { // entityRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{}) // runnerCmp := ysanity.Runner{} -// runnerCmp.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name" +// runnerCmp.One.Name = "runner.YdktestSanityOne.Name" // runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "0") // runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "1") // runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "2") @@ -195,7 +195,7 @@ func (suite *CrudTestSuite) TestDeleteOnListWithIdentitykey() { func (suite *CrudTestSuite) TestDeleteOnContainer() { runnerCreate := ysanity.Runner{} - runnerCreate.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name" + runnerCreate.One.Name = "runner.YdktestSanityOne.Name" runnerCreate.Two.Name = "runner.Two.Name" suite.CRUD.Create(&suite.Provider, &runnerCreate) @@ -204,7 +204,7 @@ func (suite *CrudTestSuite) TestDeleteOnContainer() { suite.CRUD.Update(&suite.Provider, &runnerUpdate) runnerCmp := ysanity.Runner{} - runnerCmp.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name" + runnerCmp.One.Name = "runner.YdktestSanityOne.Name" entityRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{}) @@ -249,7 +249,7 @@ func (suite *CrudTestSuite) TestDeleteOnListElement() { func (suite *CrudTestSuite) TestDeleteOnListElements() { runnerCreate := ysanity.Runner{} - runnerCreate.YdktestSanityOne.Name = "one" + runnerCreate.One.Name = "one" foo := ysanity.Runner_OneList_Ldata{} bar := ysanity.Runner_OneList_Ldata{} baz := ysanity.Runner_OneList_Ldata{} @@ -340,7 +340,7 @@ func (suite *CrudTestSuite) TestSanityReadConfig() { // TODO: Delete list using YFilter // func (suite *CrudTestSuite) TestDeleteOnList() { // runnerCreate := ysanity.Runner{} -// runnerCreate.YdktestSanityOne.Name = "one" +// runnerCreate.One.Name = "one" // foo := ysanity.Runner_OneList_Ldata{} // bar := ysanity.Runner_OneList_Ldata{} // foo.Number = 1 diff --git a/sdk/go/core/tests/service_executor_test.go b/sdk/go/core/tests/service_executor_test.go index 66719e575..8cae45c82 100644 --- a/sdk/go/core/tests/service_executor_test.go +++ b/sdk/go/core/tests/service_executor_test.go @@ -50,8 +50,8 @@ func (suite *ExecutorServiceTestSuite) TestEditCommitGet() { suite.CodecProvider.Encoding = encoding.XML runner := ysanity.Runner{} - runner.YdktestSanityOne.Number = 1 - runner.YdktestSanityOne.Name = "runner:one:name" + runner.One.Number = 1 + runner.One.Name = "runner:one:name" runnerXML := suite.CodecService.Encode(&suite.CodecProvider, &runner) // Edit Config @@ -123,8 +123,8 @@ func (suite *ExecutorServiceTestSuite) TestValidate() { suite.CodecProvider.Encoding = encoding.XML runner := ysanity.Runner{} - runner.YdktestSanityOne.Number = 1 - runner.YdktestSanityOne.Name = "runner:one:name" + runner.One.Number = 1 + runner.One.Name = "runner:one:name" runnerXML := suite.CodecService.Encode(&suite.CodecProvider, &runner) rpc = ietfNetconf.Validate{} diff --git a/sdk/go/core/tests/service_netconf_test.go b/sdk/go/core/tests/service_netconf_test.go index 5d5006dba..1378de684 100644 --- a/sdk/go/core/tests/service_netconf_test.go +++ b/sdk/go/core/tests/service_netconf_test.go @@ -47,8 +47,8 @@ func (suite *NetconfServiceTestSuite) BeforeTest(suiteName, testName string) { func (suite *NetconfServiceTestSuite) TestEditCommitGet() { runner := ysanity.Runner{} - runner.YdktestSanityOne.Number = 1 - runner.YdktestSanityOne.Name = "runner:one:name" + runner.One.Number = 1 + runner.One.Name = "runner:one:name" // Edit Config op := suite.NS.EditConfig(&suite.Provider, datastore.Candidate, &runner, "", "", "") @@ -95,8 +95,8 @@ func (suite *NetconfServiceTestSuite) TestValidate() { suite.Equal(op, true) runner := ysanity.Runner{} - runner.YdktestSanityOne.Number = 1 - runner.YdktestSanityOne.Name = "runner:one:name" + runner.One.Number = 1 + runner.One.Name = "runner:one:name" op = suite.NS.Validate(&suite.Provider, datastore.NotSet, &runner, "") suite.Equal(op, true) } diff --git a/sdk/go/core/tests/yfilters_test.go b/sdk/go/core/tests/yfilters_test.go index 248d369ae..eef1af495 100644 --- a/sdk/go/core/tests/yfilters_test.go +++ b/sdk/go/core/tests/yfilters_test.go @@ -38,12 +38,12 @@ func (suite *FiltersTestSuite) BeforeTest(suiteName, testName string) { func (suite *FiltersTestSuite) TestReadOnRefClass() { r1 := ysanity.Runner{} - r1.YdktestSanityOne.Number = 1 - r1.YdktestSanityOne.Name = "r1.YdktestSanityOne.Name" + r1.One.Number = 1 + r1.One.Name = "r1.One.Name" suite.CRUD.Create(&suite.Provider, &r1) r2 := ysanity.Runner{} - r2.YdktestSanityOne.YFilter = yfilter.Read + r2.One.YFilter = yfilter.Read entity := suite.CRUD.Read(&suite.Provider, &r2) suite.Equal(types.EntityEqual(entity, &r1), true) @@ -52,26 +52,26 @@ func (suite *FiltersTestSuite) TestReadOnRefClass() { // TODO: Encoding error if using YFilter for non-top level leaf // func (suite *FiltersTestSuite) TestReadOnLeaf() { // r1 := ysanity.Runner{} -// r1.YdktestSanityOne.Number = 1 -// r1.YdktestSanityOne.Name = "r1.YdktestSanityOne.Name" +// r1.One.Number = 1 +// r1.One.Name = "r1.One.Name" // suite.CRUD.Create(&suite.Provider, &r1) // r2 := ysanity.Runner{} -// r2.YdktestSanityOne.Number = yfilter.Read +// r2.One.Number = yfilter.Read // entity := suite.CRUD.Read(&suite.Provider, &r2) // suite.Equal(types.EntityEqual(entity, &r1), true) -// // r2.YdktestSanityOne.Number is a context match node: +// // r2.One.Number is a context match node: // // https://tools.ietf.org/html/rfc6241#section-6.2.5 -// // reads on r2.YdktestSanityOne.Number returns r2.YdktestSanityOne.Number and r2.YdktestSanityOne.Name +// // reads on r2.One.Number returns r2.One.Number and r2.One.Name // r2 = ysanity.Runner{} -// r2.YdktestSanityOne.Number = 1 +// r2.One.Number = 1 // entity = suite.CRUD.Read(&suite.Provider, &r2) // suite.Equal(types.EntityEqual(entity, &r1), true) // r2 = ysanity.Runner{} -// r2.YdktestSanityOne.Number = 2 +// r2.One.Number = 2 // entity = suite.CRUD.Read(&suite.Provider, &r2) // suite.Equal(types.EntityEqual(entity, &r2), true) @@ -161,15 +161,15 @@ func (suite *FiltersTestSuite) TestReadOnLeaflist() { // TODO: Encoding error if using YFilter for non-top level leaf // func (suite *FiltersTestSuite) TestReadOnlyConfig() { // r1 := ysanity.Runner{} -// r1.YdktestSanityOne.Number = 1 -// r1.YdktestSanityOne.Name = "r1.YdktestSanityOne.Name" +// r1.One.Number = 1 +// r1.One.Name = "r1.One.Name" // suite.CRUD.Create(&suite.Provider, &r1) // r2 := ysanity.Runner{} // r3 := ysanity.Runner{} -// r2.YdktestSanityOne.Number = yfilter.Read -// r3.YdktestSanityOne.Number = yfilter.Read +// r2.One.Number = yfilter.Read +// r3.One.Number = yfilter.Read // entity2 := suite.CRUD.ReadConfig(&suite.Provider, &r2) // entity3 := suite.CRUD.Read(&suite.Provider, &r3) @@ -177,8 +177,8 @@ func (suite *FiltersTestSuite) TestReadOnLeaflist() { // r2Read := entity2.(*ysanity.Runner) // r3Read := entity3.(*ysanity.Runner) -// suite.Equal(r2Read.YdktestSanityOne.Number, r3Read.YdktestSanityOne.Number) -// suite.Equal(r2Read.YdktestSanityOne.Name, r3Read.YdktestSanityOne.Name) +// suite.Equal(r2Read.One.Number, r3Read.One.Number) +// suite.Equal(r2Read.One.Name, r3Read.One.Name) // } func (suite *FiltersTestSuite) TestDecoder() { diff --git a/sdk/python/core/tests/test_sanity_delete.py b/sdk/python/core/tests/test_sanity_delete.py index 6fe5bbbfb..61ab208ca 100644 --- a/sdk/python/core/tests/test_sanity_delete.py +++ b/sdk/python/core/tests/test_sanity_delete.py @@ -97,14 +97,14 @@ def get_nested_object(self): def test_delete_object_on_leaf(self): # create runner with two leaves, one and two runner_create = ysanity.Runner() - runner_create.ydktest_sanity_one.name = 'one' + runner_create.one.name = 'one' runner_create.two.name = 'two' self.crud.create(self.ncc, runner_create) # use DELETE object to remove leaf one runner_update = ysanity.Runner() - runner_update.ydktest_sanity_one.name = '' - runner_update.ydktest_sanity_one.name = YFilter.delete + runner_update.one.name = '' + runner_update.one.name = YFilter.delete self.crud.update(self.ncc, runner_update) # manually create remaining runner with leaf two @@ -116,7 +116,7 @@ def test_delete_object_on_leaf(self): def test_delete_on_leaflist_slice(self): runner_create = ysanity.Runner() - runner_create.ydktest_sanity_one.name = 'one' + runner_create.one.name = 'one' runner_create.ytypes.built_in_t.llstring.extend([str(i) for i in range(5)]) self.crud.create(self.ncc, runner_create) @@ -132,7 +132,7 @@ def test_delete_on_leaflist_slice(self): runner_read = self.read_from_empty_filter() runner_compare = ysanity.Runner() - runner_compare.ydktest_sanity_one.name = 'one' + runner_compare.one.name = 'one' runner_compare.ytypes.built_in_t.llstring.extend(['1', '2', '4']) @@ -141,7 +141,7 @@ def test_delete_on_leaflist_slice(self): def test_delete_on_leaflist(self): runner_create = ysanity.Runner() - runner_create.ydktest_sanity_one.name = 'one' + runner_create.one.name = 'one' runner_create.ytypes.built_in_t.llstring.extend(['0', '1', '2', '3', '4']) self.crud.create(self.ncc, runner_create) @@ -154,7 +154,7 @@ def test_delete_on_leaflist(self): runner_read = self.read_from_empty_filter() runner_compare = ysanity.Runner() - runner_compare.ydktest_sanity_one.name = 'one' + runner_compare.one.name = 'one' runner_compare.ytypes.built_in_t.llstring.extend(['0', '1', '2', '4']) self.assertEqual(runner_compare, runner_read) @@ -163,7 +163,7 @@ def test_delete_on_leaflist(self): def test_delete_on_container(self): # create runner with a container runner_create = ysanity.Runner() - runner_create.ydktest_sanity_one.name = 'one' + runner_create.one.name = 'one' runner_create.two.name = 'two' self.crud.create(self.ncc, runner_create) @@ -177,7 +177,7 @@ def test_delete_on_container(self): runner_read = self.crud.read(self.ncc, runner_read_filter) runner_compare = ysanity.Runner() - runner_compare.ydktest_sanity_one.name = 'one' + runner_compare.one.name = 'one' self.assertEqual(runner_compare, runner_read) @@ -233,7 +233,7 @@ def test_delete_on_list_element(self): def test_delete_on_list_elements(self): runner_create = ysanity.Runner() - runner_create.ydktest_sanity_one.name = 'one' + runner_create.one.name = 'one' foo = ysanity.Runner.OneList.Ldata() bar = ysanity.Runner.OneList.Ldata() baz = ysanity.Runner.OneList.Ldata() @@ -262,7 +262,7 @@ def test_delete_on_list_elements(self): def test_delete_on_list(self): runner_create = ysanity.Runner() - runner_create.ydktest_sanity_one.name = 'one' + runner_create.one.name = 'one' foo = ysanity.Runner.OneList.Ldata() bar = ysanity.Runner.OneList.Ldata() foo.number = 1 diff --git a/sdk/python/core/tests/test_sanity_executor_rpc.py b/sdk/python/core/tests/test_sanity_executor_rpc.py index 13d19f513..d328bb6f5 100644 --- a/sdk/python/core/tests/test_sanity_executor_rpc.py +++ b/sdk/python/core/tests/test_sanity_executor_rpc.py @@ -107,8 +107,8 @@ def test_discard_changes_rpc(self): # test edit config, get config, and get rpcs def test_edit_config_rpc(self): runner = ysanity.Runner() - runner.ydktest_sanity_one.number = 1 - runner.ydktest_sanity_one.name = 'runner:one:name' + runner.one.number = 1 + runner.one.name = 'runner:one:name' runner_xml = self.cs.encode(self.csp, runner) filter_xml = self.cs.encode(self.csp, ysanity.Runner()) @@ -180,8 +180,8 @@ def test_validate_rpc_1(self): def test_validate_rpc_2(self): runner = ysanity.Runner() - runner.ydktest_sanity_one.number = 1 - runner.ydktest_sanity_one.name = 'runner:one:name' + runner.one.number = 1 + runner.one.name = 'runner:one:name' runner_xml = self.cs.encode(self.csp, runner) diff --git a/sdk/python/core/tests/test_sanity_filters.py b/sdk/python/core/tests/test_sanity_filters.py index 9e4db156f..fe440e937 100644 --- a/sdk/python/core/tests/test_sanity_filters.py +++ b/sdk/python/core/tests/test_sanity_filters.py @@ -57,22 +57,22 @@ def tearDown(self): self.crud.delete(self.ncc, runner) def test_read_on_ref_class(self): - one = ysanity.Runner.YdktestSanityOne() + one = ysanity.Runner.One() one.number, one.name = 1, 'runner:one:name' self.crud.create(self.ncc, one) - one_filter = ysanity.Runner.YdktestSanityOne() + one_filter = ysanity.Runner.One() one_read = self.crud.read(self.ncc, one_filter) self.assertIsNotNone(one_read) self.assertEqual(one, one_read) def test_read_on_leaf(self): - one = ysanity.Runner.YdktestSanityOne() + one = ysanity.Runner.One() one.number, one.name = 1, 'runner:one:name' self.crud.create(self.ncc, one) r = ysanity.Runner() - one_filter = r.ydktest_sanity_one + one_filter = r.one one_filter.name = YFilter.read one_filter.number = YFilter.read one_read = self.crud.read(self.ncc, one_filter) @@ -80,7 +80,7 @@ def test_read_on_leaf(self): self.assertEqual(one, one_read) # no such value, will return empty data - one_filter = ysanity.Runner.YdktestSanityOne() + one_filter = ysanity.Runner.One() one_filter.number = 2 one_read = self.crud.read(self.ncc, one_filter) self.assertIsNone(one_read) @@ -159,17 +159,17 @@ def test_read_on_identity_ref(self): def test_read_only_config(self): r_1 = ysanity.Runner() - r_1.ydktest_sanity_one.number, r_1.ydktest_sanity_one.name = 1, 'runner:one:name' + r_1.one.number, r_1.one.name = 1, 'runner:one:name' self.crud.create(self.ncc, r_1) r_2, r_3 = ysanity.Runner(), ysanity.Runner() - r_2.ydktest_sanity_one.number = YFilter.read - r_3.ydktest_sanity_one.number = YFilter.read + r_2.one.number = YFilter.read + r_3.one.number = YFilter.read r_2 = self.crud.read_config(self.ncc, r_2) r_3 = self.crud.read(self.ncc, r_3) # ysanity only have config data, ok to compare - self.assertEqual(r_2.ydktest_sanity_one.number, r_3.ydktest_sanity_one.number) - self.assertEqual(r_2.ydktest_sanity_one.name, r_3.ydktest_sanity_one.name) + self.assertEqual(r_2.one.number, r_3.one.number) + self.assertEqual(r_2.one.name, r_3.one.name) def test_decoder(self): # send payload to device diff --git a/sdk/python/core/tests/test_sanity_levels.py b/sdk/python/core/tests/test_sanity_levels.py index 55b5b363d..2e5e8284c 100644 --- a/sdk/python/core/tests/test_sanity_levels.py +++ b/sdk/python/core/tests/test_sanity_levels.py @@ -71,7 +71,7 @@ def _create_runner(self): def test_one_level_pos(self): # READ r_1, r_2 = Runner(), Runner() - r_1.ydktest_sanity_one.number, r_1.ydktest_sanity_one.name = 1, 'runner:one:name' + r_1.one.number, r_1.one.name = 1, 'runner:one:name' self.crud.create(self.ncc, r_1) r_2 = self.crud.read(self.ncc, r_2) @@ -79,7 +79,7 @@ def test_one_level_pos(self): # UPDATE r_1, r_2 = Runner(), Runner() - r_1.ydktest_sanity_one.number, r_1.ydktest_sanity_one.name = 10, 'runner/one/name' + r_1.one.number, r_1.one.name = 10, 'runner/one/name' self.crud.update(self.ncc, r_1) r_2 = self.crud.read(self.ncc, r_2) @@ -514,7 +514,7 @@ def test_leafref_simple_pos(self): def test_leafref_pos(self): # CREATE r_1, r_2 = Runner(), Runner() - r_1.ydktest_sanity_one.name = 'runner:one:name' + r_1.one.name = 'runner:one:name' r_1.two.sub1.number = 21 r_1.three.sub1.sub2.number = 311 e_1 = Runner.InbtwList.Ldata() @@ -543,7 +543,7 @@ def test_leafref_pos(self): e_2.subc.subc_subl1.extend([e_21, e_22]) r_1.inbtw_list.ldata.extend([e_1, e_2]) - r_1.leaf_ref.ref_one_name = r_1.ydktest_sanity_one.name + r_1.leaf_ref.ref_one_name = r_1.one.name r_1.leaf_ref.ref_two_sub1_number = r_1.two.sub1.number r_1.leaf_ref.ref_three_sub1_sub2_number = r_1.three.sub1.sub2.number r_1.leaf_ref.ref_inbtw = e_21.name @@ -555,7 +555,7 @@ def test_leafref_pos(self): # UPDATE r_1, r_2 = Runner(), Runner() - r_1.ydktest_sanity_one.name = 'runner/one/name' + r_1.one.name = 'runner/one/name' r_1.two.sub1.number = 21 r_1.three.sub1.sub2.number = 311 e_1 = Runner.InbtwList.Ldata() @@ -584,7 +584,7 @@ def test_leafref_pos(self): e_2.subc.subc_subl1.extend([e_21, e_22]) r_1.inbtw_list.ldata.extend([e_1, e_2]) - r_1.leaf_ref.ref_one_name = r_1.ydktest_sanity_one.name + r_1.leaf_ref.ref_one_name = r_1.one.name r_1.leaf_ref.ref_two_sub1_number = r_1.two.sub1.number r_1.leaf_ref.ref_three_sub1_sub2_number = r_1.three.sub1.sub2.number r_1.leaf_ref.ref_inbtw = e_21.name @@ -604,8 +604,8 @@ def test_leafref_pos(self): def test_aug_one_pos(self): # CREATE r_1, r_2 = Runner(), Runner() - r_1.ydktest_sanity_one.one_aug.number = 1 - r_1.ydktest_sanity_one.one_aug.name = "r_1.ydktest_sanity_one.one_aug.name" + r_1.one.one_aug.number = 1 + r_1.one.one_aug.name = "r_1.one.one_aug.name" self.crud.create(self.ncc, r_1) r_2 = self.crud.read(self.ncc, r_2) @@ -613,8 +613,8 @@ def test_aug_one_pos(self): # UPDATE r_1, r_2 = Runner(), Runner() - r_1.ydktest_sanity_one.one_aug.number = 10 - r_1.ydktest_sanity_one.one_aug.name = "r_1.ydktest_sanity_one.one_aug.name".replace('.', ':') + r_1.one.one_aug.number = 10 + r_1.one.one_aug.name = "r_1.one.one_aug.name".replace('.', ':') self.crud.update(self.ncc, r_1) r_2 = self.crud.read(self.ncc, r_2) diff --git a/sdk/python/core/tests/test_sanity_netconf.py b/sdk/python/core/tests/test_sanity_netconf.py index cef6df497..2561b919f 100644 --- a/sdk/python/core/tests/test_sanity_netconf.py +++ b/sdk/python/core/tests/test_sanity_netconf.py @@ -70,14 +70,14 @@ def tearDown(self): pass def test_edit_commit_get(self): - one = ysanity.Runner.YdktestSanityOne() + one = ysanity.Runner.One() one.number = 1 one.name = 'runner-one-name' op = self.netconf_service.edit_config(self.ncc, Datastore.candidate, one) self.assertEqual(True, op) - get_filter = ysanity.Runner().YdktestSanityOne() + get_filter = ysanity.Runner().One() one_result = self.netconf_service.get_config(self.ncc, Datastore.candidate, get_filter) self.assertEqual(one, one_result) @@ -111,8 +111,8 @@ def test_validate(self): self.assertEqual(True, op) runner = ysanity.Runner() - runner.ydktest_sanity_one.number = 1 - runner.ydktest_sanity_one.name = 'runner-one-name' + runner.one.number = 1 + runner.one.name = 'runner-one-name' op = self.netconf_service.validate(self.ncc, source=runner) self.assertEqual(True, op) @@ -430,17 +430,17 @@ def test_crud_get_all(self): self.logger.error("Failed to get device state due to error: {}".format(err.message)) def test_passive_interface(self): - ospf = ysanity.Runner.YdktestSanityOne.Ospf() + ospf = ysanity.Runner.One.Ospf() ospf.id = 22 ospf.passive_interface.interface = "xyz" - test = ysanity.Runner.YdktestSanityOne.Ospf.Test() + test = ysanity.Runner.One.Ospf.Test() test.name = "abc" ospf.test.append(test) op = self.netconf_service.edit_config(self.ncc, Datastore.candidate, ospf) self.assertEqual(True, op) - ospf_filter = ysanity.Runner().YdktestSanityOne().Ospf() + ospf_filter = ysanity.Runner.One.Ospf() ospf_filter.id = 22 ospf_result = self.netconf_service.get_config(self.ncc, Datastore.candidate, ospf_filter) self.assertIsNotNone(ospf_result) diff --git a/sdk/python/core/tests/test_sanity_service_errors.py b/sdk/python/core/tests/test_sanity_service_errors.py index 4827c7362..0716fcf31 100644 --- a/sdk/python/core/tests/test_sanity_service_errors.py +++ b/sdk/python/core/tests/test_sanity_service_errors.py @@ -231,8 +231,8 @@ def setUp(self): def test_execute_rpc_invalid_1(self): runner = ysanity.Runner() - runner.ydktest_sanity_one.number = 1 - runner.ydktest_sanity_one.name = 'runner:one:name' + runner.one.number = 1 + runner.one.name = 'runner:one:name' edit_rpc = ietf_netconf.EditConfig() edit_rpc.input.target.candidate = Empty() @@ -266,8 +266,8 @@ def test_execute_rpc_invalid_3(self): def _create_runner(): runner = ysanity.Runner() - runner.ydktest_sanity_one.number = 1 - runner.ydktest_sanity_one.name = 'runner:one:name' + runner.one.number = 1 + runner.one.name = 'runner:one:name' return runner class SanityNetconf(unittest.TestCase): diff --git a/sdk/python/core/tests/test_sanity_type_mismatch_errors.py b/sdk/python/core/tests/test_sanity_type_mismatch_errors.py index b63b69cfb..f1b470b95 100644 --- a/sdk/python/core/tests/test_sanity_type_mismatch_errors.py +++ b/sdk/python/core/tests/test_sanity_type_mismatch_errors.py @@ -74,32 +74,32 @@ def tearDown(self): @assert_with_error(test_invalid_class_assignment_int_pattern, YModelError) def test_invalid_class_assignment_int(self): runner = ysanity.Runner() - runner.ydktest_sanity_one = 1 + runner.one = 1 self.crud.create(self.ncc, runner) @assert_with_error(test_invalid_class_assignment_str_pattern, YModelError) def test_invalid_class_assignment_str(self): runner = ysanity.Runner() - runner.ydktest_sanity_one = "haha" + runner.one = "haha" self.crud.create(self.ncc, runner) @assert_with_error(test_invalid_class_assignment_identity_pattern, YModelError) def test_invalid_class_assignment_identity(self): runner = ysanity.Runner() - runner.ydktest_sanity_one = ytypes.AnotherOne() + runner.one = ytypes.AnotherOne() self.crud.create(self.ncc, runner) @assert_with_error(test_invalid_class_assignment_enum_pattern, YModelError) def test_invalid_class_assignment_enum(self): runner = ysanity.Runner() - runner.ydktest_sanity_one = ysanity.YdkEnumTest.none + runner.one = ysanity.YdkEnumTest.none self.crud.create(self.ncc, runner) @assert_with_error(test_invalid_class_assignment_yleaflist_pattern, YModelError) def test_invalid_class_assignment_yleaflist(self): runner = ysanity.Runner() runner.ytypes.built_in_t.llstring.extend([str(i) for i in range(5)]) - runner.ydktest_sanity_one = runner.ytypes.built_in_t.llstring + runner.one = runner.ytypes.built_in_t.llstring @assert_with_error(test_invalid_list_assignment_int_pattern, YModelError) def test_invalid_list_assignment_int(self): @@ -110,7 +110,7 @@ def test_invalid_list_assignment_int(self): @assert_with_error(test_invalid_list_assignment_entity_pattern, YModelError) def test_invalid_list_assignment_entity(self): runner = ysanity.Runner() - runner.one_list.ldata = runner.ydktest_sanity_one + runner.one_list.ldata = runner.one self.crud.crud(self.ncc, runner) @assert_with_error(test_invalid_list_assignment_llist_pattern, YModelError) diff --git a/ydkgen/api_model.py b/ydkgen/api_model.py index bb254cc77..5ff88dc36 100644 --- a/ydkgen/api_model.py +++ b/ydkgen/api_model.py @@ -231,12 +231,12 @@ def go_name(self): if hasattr(self, 'goName'): return self.goName - name = escape_name(stmt.unclashed_arg if hasattr(stmt, 'unclashed_arg') else stmt.arg) - name = camel_case(name) + stmt_name = escape_name(stmt.unclashed_arg if hasattr(stmt, 'unclashed_arg') else stmt.arg) + name = camel_case(stmt_name) + if stmt_name[-1] == '_': + name = '%s_' % name if self.iskeyword(name): - name = '%s%s' % ('Y', name) - # suffix = '_' if self.name[-1] == '_' else '' - # name = '%s%s' % (name, suffix) + name = 'Y%s' % name self.goName = name return self.goName diff --git a/ydkgen/builder/_api_model_builder.py b/ydkgen/builder/_api_model_builder.py index 26e5048d3..209c1c5f7 100644 --- a/ydkgen/builder/_api_model_builder.py +++ b/ydkgen/builder/_api_model_builder.py @@ -298,6 +298,11 @@ def _create_expanded_api_model(self, stmt, parent_element, deviation_packages): for e in parent_element.owned_elements: if e.name == clazz.name: clazz.name = clazz.name + '_' + if hasattr(stmt, 'unclashed_arg'): + stmt.unclashed_arg += '_' + else: + stmt.unclashed_arg = '%s_' % stmt.arg + parent_element.owned_elements.append(clazz) clazz.set_owner(parent_element, self.language) @@ -316,7 +321,8 @@ def _create_expanded_api_model(self, stmt, parent_element, deviation_packages): for e in parent_element.owned_elements: if isinstance(e, Property): s = snake_case(e.stmt.arg) - if snake_case(prop.stmt.arg) == s: + stmt_arg = (prop.stmt.unclashed_arg if hasattr(prop.stmt, 'unclashed_arg') else prop.stmt.arg) + if snake_case(stmt_arg) == s: prop.name = prop.name + '_' parent_element.owned_elements.append(prop) @@ -329,7 +335,7 @@ def _create_expanded_api_model(self, stmt, parent_element, deviation_packages): self._add_to_deviation_package(stmt, parent_element, deviation_packages) # walk the children - _keywords = statements.data_definition_keywords + ['case', 'rpc', 'input', 'output'] + _keywords = statements.data_definition_keywords + ['case', 'rpc', 'input', 'output', 'choice'] if hasattr(stmt, 'i_children'): self._sanitize_namespace(stmt) @@ -375,28 +381,37 @@ def _sanitize_namespace(self, stmt): :param `pyang.statements.Statement` The stmt to sanitize. """ def _get_num_clashes(i_children): - stmts = [stmt for stmt in i_children] + stmts = [] + for stmt in i_children: + if stmt.keyword in ['container', 'list', 'leaf', 'leaf-list']: + stmts.append(stmt) + elif stmt.keyword == 'choice': + for choice_child in stmt.i_children: + if choice_child.keyword == 'case': + choice_child = choice_child.i_children[0] + if choice_child.keyword in ['container', 'list', 'leaf', 'leaf-list']: + stmts.append(choice_child) + all_stmts = [stmt for stmt in stmts] clashes = [] - while len(stmts) > 0: ss = stmts.pop() - if ss.arg in [s.arg for s in stmts] and ss.arg not in clashes: + sargs = [s.arg for s in stmts] + if ss.arg in sargs and ss.arg not in clashes: clashes.append(ss.arg) - - return clashes + return clashes, all_stmts def _kill_clash(clash, i_children): for stmt in i_children: if clash == stmt.arg: - old_arg = stmt.arg - new_arg = '%s_%s' % (stmt.top.arg, old_arg) - stmt.unclashed_arg = new_arg #stmt.arg = new_arg - - clashes = _get_num_clashes(stmt.i_children) + if hasattr(stmt, 'i_augment'): + stmt.unclashed_arg = '%s_%s' % (stmt.top.arg, stmt.arg) + elif stmt.parent.keyword == 'case' and hasattr(stmt.parent.parent, 'i_augment'): + stmt.unclashed_arg = '%s_%s' % (stmt.parent.parent.top.arg, stmt.arg) + clashes, stmts = _get_num_clashes(stmt.i_children) if len(clashes) > 0: for clash in clashes: - _kill_clash(clash, stmt.i_children) + _kill_clash(clash, stmts) class SubModuleBuilder(object):