Ejemplo n.º 1
0
    def test_apply(self):
        file_dict = {"f_a": ["1", "2", "3"], "f_b": ["1", "2", "3"]}
        expected_file_dict = {
            "f_a": ["1", "3_changed"],
            "f_b": ["1", "2", "3"]
        }
        diff = Diff()
        diff.delete_line(2)
        diff.change_line(3, "3", "3_changed")

        uut = PatchResult("origin", "msg", {"f_a": diff})
        uut.apply(file_dict)

        self.assertEqual(file_dict, expected_file_dict)

        uut = PatchResult("origin", "msg", {})
        for action in uut.get_actions():
            action.apply(
                uut, {},
                {})  # All those actions should be able to apply this result

        self.assertEqual(len(uut.get_actions()), 1)
Ejemplo n.º 2
0
    def test_apply(self):
        file_dict = {
            "f_a": ["1", "2", "3"],
            "f_b": ["1", "2", "3"]
        }
        expected_file_dict = {
            "f_a": ["1", "3_changed"],
            "f_b": ["1", "2", "3"]
        }
        diff = Diff()
        diff.delete_line(2)
        diff.change_line(3, "3", "3_changed")

        uut = PatchResult("origin", "msg", {"f_a": diff})
        uut.apply(file_dict)

        self.assertEqual(file_dict, expected_file_dict)

        uut = PatchResult("origin", "msg", {})
        for action in uut.get_actions():
            action.apply(uut, {}, {})  # All those actions should be able to apply this result

        self.assertEqual(len(uut.get_actions()), 1)