コード例 #1
0
ファイル: rw_ks_pytest.py プロジェクト: RIFTIO/RIFT.ware
 def test_gi_keyspec_string_method(self):
     #create a keyspec that points to a leaf node
     xpath = "D,/rw-base:colony[rw-base:name=\'abc\']/rw-fpath:bundle-ether[rw-fpath:name=\'xyz\']/rw-base:mtu"
     schema = RwFpathDYang.get_schema()
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertFalse(keyspec)
     xpath = "D,/rw-base:colony[rw-base:name=\'abc\']/rw-fpath:bundle-ether[rw-fpath:name=\'xyz\']/rw-fpath:mtu"
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     v_create_string =  keyspec.create_string(schema)
     v_create_string_no_schema =  keyspec.create_string()
     print("create_string           = %s" % (v_create_string,))
     print("create_string_no_schema = %s" % (v_create_string_no_schema,))
     self.assertEqual(v_create_string, xpath)
コード例 #2
0
 def test_gi_keyspec_string_method(self):
     #create a keyspec that points to a leaf node
     xpath = "D,/rw-base:colony[rw-base:name=\'abc\']/rw-fpath:bundle-ether[rw-fpath:name=\'xyz\']/rw-base:mtu"
     schema = RwFpathDYang.get_schema()
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertFalse(keyspec)
     xpath = "D,/rw-base:colony[rw-base:name=\'abc\']/rw-fpath:bundle-ether[rw-fpath:name=\'xyz\']/rw-fpath:mtu"
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     v_create_string =  keyspec.create_string(schema)
     v_create_string_no_schema =  keyspec.create_string()
     print("create_string           = %s" % (v_create_string,))
     print("create_string_no_schema = %s" % (v_create_string_no_schema,))
     self.assertEqual(v_create_string, xpath)
コード例 #3
0
ファイル: rw_ks_pytest.py プロジェクト: RIFTIO/RIFT.ware
 def test_gi_get_pbcmd_from_xpath(self):
     xpath = "D,/rw-base:colony[rw-base:name='trafgen']"
     schema = RwFpathDYang.get_schema()
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony().retrieve_descriptor())
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony_BundleEther().retrieve_descriptor())
     #container
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']/rw-fpath:lacp"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony_BundleEther_Lacp().retrieve_descriptor())
     #leaf, should give error
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']/rw-fpath:open"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertFalse(pbcmd);
コード例 #4
0
 def test_gi_get_pbcmd_from_xpath(self):
     xpath = "D,/rw-base:colony[rw-base:name='trafgen']"
     schema = RwFpathDYang.get_schema()
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony().retrieve_descriptor())
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony_BundleEther().retrieve_descriptor())
     #container
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']/rw-fpath:lacp"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertTrue(pbcmd)
     self.assertEqual(pbcmd, RwFpathDYang.ConfigColony_BundleEther_Lacp().retrieve_descriptor())
     #leaf, should give error
     xpath = "/rw-base:colony[rw-base:name='trafgen']/rw-fpath:bundle-ether[rw-fpath:name='bundle1']/rw-fpath:open"
     pbcmd = RwKeyspec.get_pbcmd_from_xpath(xpath, schema)
     self.assertFalse(pbcmd);
コード例 #5
0
ファイル: rw_ks_pytest.py プロジェクト: RIFTIO/RIFT.ware
 def test_gi_schema_context_methods(self):
     #create a keyspec that points to a leaf node
     xpath = "/rw-base:colony[rw-base:name=\'trafgen\']/rw-fpath:bundle-ether[rw-fpath:name=\'bundle1\']/rw-fpath:mtu"
     schema = RwFpathDYang.get_schema()
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     gi_desc = RwFpathDYang.ConfigColony_BundleEther.schema()
     self.assertTrue(gi_desc);
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertTrue(lname)
     print("Leaf " + lname)
     self.assertEqual(lname, "mtu")
     #Error case not a leaf keyspec
     xpath = "/rw-base:colony[rw-base:name=\'trafgen\']/rw-fpath:bundle-ether[rw-fpath:name=\'bundle1\']"
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertFalse(lname);
     #Error wrong schema
     gi_desc = RwFpathDYang.ConfigColony.schema()
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertFalse(lname)
コード例 #6
0
 def test_gi_schema_context_methods(self):
     #create a keyspec that points to a leaf node
     xpath = "/rw-base:colony[rw-base:name=\'trafgen\']/rw-fpath:bundle-ether[rw-fpath:name=\'bundle1\']/rw-fpath:mtu"
     schema = RwFpathDYang.get_schema()
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     gi_desc = RwFpathDYang.ConfigColony_BundleEther.schema()
     self.assertTrue(gi_desc);
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertTrue(lname)
     print("Leaf " + lname)
     self.assertEqual(lname, "mtu")
     #Error case not a leaf keyspec
     xpath = "/rw-base:colony[rw-base:name=\'trafgen\']/rw-fpath:bundle-ether[rw-fpath:name=\'bundle1\']"
     keyspec = RwKeyspec.path_from_xpath(schema, xpath, RwKeyspec.RwXpathType.KEYSPEC)
     self.assertTrue(keyspec)
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertFalse(lname);
     #Error wrong schema
     gi_desc = RwFpathDYang.ConfigColony.schema()
     lname = gi_desc.keyspec_leaf(keyspec)
     self.assertFalse(lname)