コード例 #1
0
    def test_replace_on_leaf(self):
        one = Runner.One()
        one.number, one.name = 1, 'runner-one-name'
        self.crud.create(self.ncc, one)

        filter = Runner.One()
        filter.number = READ()
        r = self.crud.read(self.ncc, filter)
        self.assertEqual(r.number, one.number)

        # Replace leaf value and verify
        one = Runner.One()
        one.name = REPLACE('runner_one_name')
        one.number = MERGE(2)
        self.crud.update(self.ncc, one)

        filter = Runner.One()
        filter.name = READ()
        filter.number = READ()
        r = self.crud.read(self.ncc, filter)
        self.assertEqual(r.name, 'runner_one_name')
        self.assertEqual(r.number, 2)

        one = Runner.One()
        one.number = REMOVE()
        self.crud.update(self.ncc, one)

        one.number = CREATE(3)
        self.crud.update(self.ncc, one)

        r = self.crud.read(self.ncc, Runner.One())
        self.assertEqual(r.name, 'runner_one_name')
        self.assertEqual(r.number, 3)
コード例 #2
0
    def test_read_only_config(self):
        r_1 = Runner()
        r_1.one.number, r_1.one.name = 1, 'runner:one:name'
        self.crud.create(self.ncc, r_1)
        r_2, r_3 = Runner(), Runner()
        r_2.one.number, r_3.one.number = READ(), READ()

        r_2 = self.crud.read(self.ncc, r_2, only_config=True)
        r_3 = self.crud.read(self.ncc, r_3)
        # ysanity only have config data, ok to compare
        self.assertEqual(is_equal(r_2, r_3), True)
コード例 #3
0
 def test_read_only_config(self):
     r_1 = ysanity.Runner()
     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.one.number, r_3.one.number = READ(), READ()
     # only_config=True will change
     # <get>XML</get>
     # to
     # <get-config><source><running/></source>XML</get-config>
     r_2 = self.crud.read(self.ncc, r_2, only_config=True)
     r_3 = self.crud.read(self.ncc, r_3)
     # ysanity only have config data, ok to compare
     self.assertEqual(is_equal(r_2, r_3), True)
コード例 #4
0
 def test_CASE3(self):
     a = ysanity.A()
     a.a1 = READ()
     a = self.crud.read(self.ncc, a)
     _a = ysanity.A()
     _a.a1 = "some value"
     self.assertEqual(is_equal(a, _a), True)
コード例 #5
0
 def test_CASE3(self):
     """Assign a READ object to `a.a1` should only return data on this leaf."""
     a = ysanity.A()
     a.a1 = READ()
     a_read = self.crud.read(self.ncc, a)
     preconfig_a = ysanity.A()
     preconfig_a.a1 = "some value"
     self.assertEqual(is_equal(a_read, preconfig_a), True)
コード例 #6
0
 def test_read_on_identity_ref(self):
     r_1 = ysanity.Runner.Ytypes.BuiltInT()
     r_1.identity_ref_value = ysanity.ChildIdentity_Identity()
     self.crud.create(self.ncc, r_1)
     r_2 = ysanity.Runner.Ytypes.BuiltInT()
     r_2.identity_ref_value = READ()
     r_2 = self.crud.read(self.ncc, r_2)
     self.assertEqual(is_equal(r_1, r_2), True)
コード例 #7
0
    def test_read_on_ref_class(self):
        r_1 = Runner()
        r_1.one.number, r_1.one.name = 1, 'runner:one:name'
        self.crud.create(self.ncc, r_1)
        r_2 = Runner()

        r_2.one = READ()
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertEqual(is_equal(r_1, r_2), True)
コード例 #8
0
    def test_create_identity_ref(self):
        # Create and Verify
        btc = Runner.Ytypes.BuiltInT()
        btc.identity_ref_value = CREATE(ChildIdentityIdentity())
        self.crud.update(self.ncc, btc)

        filter = Runner.Ytypes.BuiltInT()
        filter.identity_ref_value = READ()
        r = self.crud.read(self.ncc, filter)
        self.assertTrue(is_equal(r.identity_ref_value,
                                 ChildIdentityIdentity()))
コード例 #9
0
    def test_read_on_ref_list(self):
        r_1 = Runner.OneList()
        l_1, l_2 = Runner.OneList.Ldata(), Runner.OneList.Ldata()
        l_1.number, l_2.number = 1, 2
        r_1.ldata.extend([l_1, l_2])
        self.crud.create(self.ncc, r_1)

        r_2 = Runner.OneList()
        r_2.ldata = READ()
        r_2 = self.crud.read(self.ncc, r_2)

        self.assertEqual(is_equal(r_1, r_2), True)
コード例 #10
0
    def test_read_on_leaflist(self):
        r_1 = ysanity.Runner.Ytypes.BuiltInT()
        r_1.llstring = ['1', '2', '3']
        self.crud.create(self.ncc, r_1)
        r_2 = ysanity.Runner.Ytypes.BuiltInT()
        r_2.llstring = READ()
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertEqual(is_equal(r_1, r_2), True)

        r_2 = ysanity.Runner.Ytypes.BuiltInT()
        # invalid input, user should use READ()
        # or the same data on device
        r_2.llstring = ['something emaillse']
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertNotEqual(is_equal(r_1, r_2), True)
コード例 #11
0
    def test_replace_on_enum(self):
        # Create and verify
        btc = Runner.Ytypes.BuiltInT()
        btc.enum_value = YdkEnumTestEnum.local
        self.crud.create(self.ncc, btc)

        filter = Runner.Ytypes.BuiltInT()
        filter.enum_value = READ()
        r = self.crud.read(self.ncc, filter)
        self.assertTrue(is_equal(r, btc))

        # Replace and Verify
        btr = Runner.Ytypes.BuiltInT()
        btr.enum_value = REPLACE(YdkEnumTestEnum.remote)
        self.crud.update(self.ncc, btr)

        r = self.crud.read(self.ncc, filter)
        self.assertEqual(r.enum_value, YdkEnumTestEnum.remote)
コード例 #12
0
    def test_read_on_ref_enum_class(self):
        r_1 = Runner.Ytypes.BuiltInT()
        r_1.enum_value = YdkEnumTestEnum.local
        self.crud.create(self.ncc, r_1)

        r_2 = Runner.Ytypes.BuiltInT()
        r_2.enum_value = READ()
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertEqual(is_equal(r_1, r_2), True)

        r_2 = Runner.Ytypes.BuiltInT()
        r_2.enum_value = YdkEnumTestEnum.local
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertEqual(is_equal(r_1, r_2), True)

        # no such value, nothing returned
        r_2 = Runner.Ytypes.BuiltInT()
        r_2.enum_value = YdkEnumTestEnum.remote
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertNotEqual(is_equal(r_1, r_2), True)
コード例 #13
0
    def test_read_on_leaf(self):
        r_1 = Runner()
        r_1.one.number, r_1.one.name = 1, 'runner:one:name'
        self.crud.create(self.ncc, r_1)
        r_2 = Runner()
        r_2.one.number = READ()
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertEqual(r_2.one.number, r_1.one.number)

        # this will also read r_2.one.name, not able to read only one of them
        r_2 = Runner()
        r_2.one.number = 1
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertEqual(r_2.one.number, r_1.one.number)

        # no such value, will return empty data
        r_2 = Runner()
        r_2.one.number = 2
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertNotEqual(r_2.one.number, r_1.one.number)
コード例 #14
0
    def test_read_on_ref_enum_class(self):
        from ydk.models.ydktest.ydktest_sanity import YdkEnumTestEnum
        r_1 = ysanity.Runner.Ytypes.BuiltInT()
        r_1.enum_value = YdkEnumTestEnum.LOCAL
        self.crud.create(self.ncc, r_1)

        r_2 = ysanity.Runner.Ytypes.BuiltInT()
        r_2.enum_value = READ()
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertEqual(is_equal(r_1, r_2), True)

        r_2 = ysanity.Runner.Ytypes.BuiltInT()
        r_2.enum_value = YdkEnumTestEnum.LOCAL
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertEqual(is_equal(r_1, r_2), True)

        # no such value, nothing returned
        r_2 = ysanity.Runner.Ytypes.BuiltInT()
        r_2.enum_value = YdkEnumTestEnum.REMOTE
        r_2 = self.crud.read(self.ncc, r_2)
        self.assertNotEqual(is_equal(r_1, r_2), True)