Exemple #1
0
    def test_entity_diff_two_key(self):
        runner = ysanity.Runner()
        l_1, l_2 = ysanity.Runner.TwoKeyList(), ysanity.Runner.TwoKeyList()
        l_1.first, l_2.first = 'f1', 'f2'
        l_1.second, l_2.second = 11, 22
        l_1.property, l_2.property = '82', '83'
        runner.two_key_list.extend([l_1, l_2])

        ent_dict = entity_to_dict(runner)
        self.assertEqual(len(ent_dict), 4)
        print_dictionary('-LEFT', ent_dict)

        runner2 = ysanity.Runner()
        l_1, l_2 = ysanity.Runner.TwoKeyList(), ysanity.Runner.TwoKeyList()
        l_1.first, l_2.first = 'f1', 'f2'
        l_1.second, l_2.second = 11, 22
        l_1.property, l_2.property = '82', '83'
        runner2.two_key_list.extend([l_1, l_2])

        diff = entity_diff(runner, runner2)
        self.assertEqual(len(diff), 0)

        l_1.property = '83'
        print_dictionary('-RIGHT', entity_to_dict(runner2))
        diff = entity_diff(runner, runner2)
        self.assertEqual(len(diff), 1)
        self.print_diffs(diff, runner, runner2)
Exemple #2
0
    def test_entity_to_dict_no_key_list(self):
        r_1 = ysanity.Runner()
        test1 = ysanity.Runner.NoKeyList()
        test1.test = 't1'
        test2 = ysanity.Runner.NoKeyList()
        test2.test = 't2'
        r_1.no_key_list.extend([test1, test2])
        ent_dict = entity_to_dict(r_1)
        self.assertEqual(len(ent_dict), 4)
        print_dictionary('-LEFT', ent_dict, 50)

        r_2 = ysanity.Runner()
        test1 = ysanity.Runner.NoKeyList()
        test1.test = 't1'
        test2 = ysanity.Runner.NoKeyList()
        test2.test = 'tt'
        test3 = ysanity.Runner.NoKeyList()
        test3.test = 't3'
        r_2.no_key_list.extend([test1, test2, test3])
        ent_dict = entity_to_dict(r_2)
        self.assertEqual(len(ent_dict), 6)
        print_dictionary('-RIGHT', ent_dict, 50)

        diff = entity_diff(r_1, r_2)
        self.assertEqual(len(diff), 2)
        self.print_diffs(diff, r_1, r_2, 30)
Exemple #3
0
    def test_entity_diff_twolist_pos(self):
        r_1 = ysanity.Runner()
        e_1, e_2 = ysanity.Runner.TwoList.Ldata(
        ), ysanity.Runner.TwoList.Ldata()
        e_11, e_12 = ysanity.Runner.TwoList.Ldata.Subl1(
        ), ysanity.Runner.TwoList.Ldata.Subl1()
        e_1.number = 21
        e_1.name = 'runner:twolist:ldata[' + str(e_1.number) + ']:name'
        e_11.number = 211
        e_11.name = 'runner:twolist:ldata[' + str(
            e_1.number) + ']:subl1[' + str(e_11.number) + ']:name'
        e_12.number = 212
        e_12.name = 'runner:twolist:ldata[' + str(
            e_1.number) + ']:subl1[' + str(e_12.number) + ']:name'
        e_1.subl1.append(e_11)
        e_1.subl1.append(e_12)
        e_21, e_22 = ysanity.Runner.TwoList.Ldata.Subl1(
        ), ysanity.Runner.TwoList.Ldata.Subl1()
        e_2.number = 22
        e_2.name = 'runner:twolist:ldata[' + str(e_2.number) + ']:name'
        e_21.number = 221
        e_21.name = 'runner:twolist:ldata[' + str(
            e_2.number) + ']:subl1[' + str(e_21.number) + ']:name'
        e_22.number = 222
        e_22.name = 'runner:twolist:ldata[' + str(
            e_2.number) + ']:subl1[' + str(e_22.number) + ']:name'
        e_2.subl1.append(e_21)
        e_2.subl1.append(e_22)
        r_1.two_list.ldata.append(e_1)
        r_1.two_list.ldata.append(e_2)

        ent_dict = entity_to_dict(r_1)
        self.assertEqual(len(ent_dict), 12)
        print_dictionary('-LEFT', ent_dict, 80)

        r_2 = ysanity.Runner()
        e_1, e_2 = ysanity.Runner.TwoList.Ldata(
        ), ysanity.Runner.TwoList.Ldata()
        e_11, e_12 = ysanity.Runner.TwoList.Ldata.Subl1(
        ), ysanity.Runner.TwoList.Ldata.Subl1()
        e_1.number = 21
        e_1.name = 'runner:twolist:ldata[' + str(e_1.number) + ']:name'
        e_11.number = 211
        e_11.name = 'runner:twolist:ldata[' + str(
            e_1.number) + ']:subl1[' + str(e_11.number) + ']:name'
        e_12.number = 212
        e_12.name = 'runner:twolist:ldata[' + str(
            e_1.number) + ']:subl1[' + str(e_12.number) + ']:name'
        e_1.subl1.append(e_11)
        e_1.subl1.append(e_12)
        r_2.two_list.ldata.append(e_1)

        ent_dict = entity_to_dict(r_2)
        self.assertEqual(len(ent_dict), 6)
        print_dictionary('-RIGHT', ent_dict, 80)

        diff = entity_diff(r_1, r_2)
        self.assertEqual(len(diff), 1)
        print_diffs(diff, 50)
Exemple #4
0
    def test_entity_to_dict_presence(self):
        runner = ysanity.Runner()
        runner.runner_2 = ysanity.Runner.Runner2()
        runner.runner_2.some_leaf = 'some-leaf'

        ent_dict = entity_to_dict(runner)
        self.assertEqual(len(ent_dict), 2)
        print_dictionary('-LEFT', ent_dict, 40)

        runner_ = ysanity.Runner()
        ent_dict = entity_to_dict(runner_)
        self.assertEqual(len(ent_dict), 0)
        print_dictionary('-RIGHT', ent_dict, 40)

        diff = entity_diff(runner, runner_)
        self.assertEqual(len(diff), 1)
        self.print_diffs(diff, runner, runner_, 40)
Exemple #5
0
    def test_entity_diff_number_leaf(self):
        runner1 = ysanity.Runner()
        runner1.ytypes.built_in_t.number8 = 23

        ent_dict = entity_to_dict(runner1)
        self.assertEqual(len(ent_dict), 1)
        print_dictionary('-LEFT', ent_dict, 50)

        runner2 = ysanity.Runner()

        ent_dict = entity_to_dict(runner2)
        self.assertEqual(len(ent_dict), 0)
        print_dictionary('-RIGHT', ent_dict, 50)

        diff = entity_diff(runner1, runner2)
        self.assertEqual(len(diff), 1)
        self.print_diffs(diff, runner1, runner2, 50)