예제 #1
0
    def test_operations_returns_expected_delete(self):
        operations = get_operations(
            TestClass.TEST_LIST_DELETE, TestClass.TEST_LIST_BASE)

        expected = TestClass.TEST_OPERATION_LIST_DELETE

        self.assertEqual(expected, operations)
예제 #2
0
    def test_operations_returns_expected_replace(self):
        operations = get_operations(
            TestClass.TEST_LIST_REPLACE, TestClass.TEST_LIST_BASE)

        expected = TestClass.TEST_OPERATION_LIST_REPLACE

        self.assertEqual(expected, operations)
예제 #3
0
    def test_operations_returns_expected_insert(self):
        operations = get_operations(
            TestClass.TEST_LIST_INSERT, TestClass.TEST_LIST_BASE)

        expected = TestClass.TEST_OPERATION_LIST_INSERT

        self.assertEqual(expected, operations)
예제 #4
0
    def test_parse_returns_expected_with_same(self):
        correct, diff = _parse_operations(
            TestClass.TEST_LIST_BASE, TestClass.TEST_LIST_BASE,
            get_operations(TestClass.TEST_LIST_BASE, TestClass.TEST_LIST_BASE))
        expected_correct = TestClass.TEST_LIST_BASE
        expected_diff = {}

        self.assertEqual(expected_correct, correct)
        self.assertEqual(expected_diff, diff)
예제 #5
0
    def test_parse_returns_expected_with_different_delete(self):
        correct, diff = _parse_operations(
            TestClass.TEST_LIST_DELETE, TestClass.TEST_LIST_BASE,
            get_operations(TestClass.TEST_LIST_DELETE,
                           TestClass.TEST_LIST_BASE))
        expected_correct = TestClass.TEST_LIST_BASE
        expected_diff = {'extra': ''}

        self.assertEqual(expected_correct, correct)
        self.assertEqual(expected_diff, diff)
예제 #6
0
    def test_parse_returns_expected_with_different_insert(self):
        correct, diff = _parse_operations(
            TestClass.TEST_LIST_INSERT, TestClass.TEST_LIST_BASE,
            get_operations(TestClass.TEST_LIST_INSERT,
                           TestClass.TEST_LIST_BASE))
        expected_correct = TestClass.TEST_LIST_BASE[:-1]
        expected_diff = {'': 'string'}

        self.assertEqual(expected_correct, correct)
        self.assertEqual(expected_diff, diff)
예제 #7
0
    def test_parse_returns_expected_with_different_replace(self):
        correct, diff = _parse_operations(
            TestClass.TEST_LIST_REPLACE, TestClass.TEST_LIST_BASE,
            get_operations(TestClass.TEST_LIST_REPLACE,
                           TestClass.TEST_LIST_BASE))
        expected_correct = TestClass.TEST_LIST_BASE[:-1]
        expected_diff = {'false': 'string'}

        self.assertEqual(expected_correct, correct)
        self.assertEqual(expected_diff, diff)
예제 #8
0
    def test_parse_returns_expected_with_different_list_replace_multiple_list(
            self):
        comparable = ['not', 'is', 'not', 'is', 'not']
        base = ['it', 'is', 'a', 'is', 'test']
        correct, diff = _parse_operations(comparable, base,
                                          get_operations(comparable, base))
        expected_correct = ['is']
        expected_diff = {'not': ['it', 'a', 'test']}

        self.assertEqual(set(expected_correct), set(correct))
        self.assertEqual(expected_diff, diff)
예제 #9
0
    def test_parse_returns_expected_with_different_list_replace_multiple_for_same(
            self):
        base = TestClass.TEST_LIST_BASE + ['list', 'test']
        correct, diff = _parse_operations(
            self.TEST_REPLACE_REPEATED_MULTIPLE, base,
            get_operations(self.TEST_REPLACE_REPEATED_MULTIPLE, base))
        expected_correct = [
            element for element in base if element not in ['test', 'string']
        ]
        expected_diff = {'false': ['string', ['test', 2]]}

        self.assertEqual(set(expected_correct), set(correct))
        self.assertEqual(expected_diff, diff)
예제 #10
0
    def test_parse_returns_expected_with_different_replace_groups(self):
        correct, diff = _parse_operations(
            self.TEST_REPLACE_REPEATED, self.TEST_REPEATED,
            get_operations(self.TEST_REPLACE_REPEATED,
                           TestClass.TEST_LIST_BASE))
        expected_correct = [
            element for element in self.TEST_REPLACE_REPEATED
            if element != 'false'
        ]
        expected_diff = {'false': ['test', 2]}

        self.assertEqual(expected_correct, correct)
        self.assertEqual(expected_diff, diff)
예제 #11
0
    def test_parse_returns_expected_with_different_replace_groups_multiple(
            self):
        base = self.TEST_REPEATED_MULTIPLE
        correct, diff = _parse_operations(
            self.TEST_REPLACE_REPEATED_MULTIPLE, base,
            get_operations(self.TEST_REPLACE_REPEATED_MULTIPLE, base))
        expected_correct = [
            element for element in self.TEST_REPLACE_REPEATED
            if element != 'false'
        ]
        expected_diff = {'false': ['test', 3]}

        self.assertEqual(expected_correct, correct)
        self.assertEqual(expected_diff, diff)
예제 #12
0
    def test_json_computed_correctly_string(self):
        comparable, base = _format_input(TestClass.TEST_STRING_REPLACE,
                                         TestClass.TEST_STRING_BASE)
        operations = get_operations(comparable, base)
        result = _three_way_diff_compute(TestClass.TEST_STRING_REPLACE,
                                         TestClass.TEST_STRING_REPLACE,
                                         TestClass.TEST_STRING_BASE)

        comparable_result, comparable_diff = _parse_operations(
            comparable, base, operations)

        assert result['correct']['comparable1'] == comparable_result
        assert result['correct']['comparable2'] == comparable_result
        assert result['diff']['comparable1'] == comparable_diff
        assert result['diff']['comparable2'] == comparable_diff

        accuracy = _compute_accuracy(operations, base)
        assert result['accuracy']['comparable1'] == accuracy
        assert result['accuracy']['comparable2'] == accuracy
예제 #13
0
    def test_operations_returns_all_nothing_with_equal(self):
        operations = get_operations(
            TestClass.TEST_LIST_BASE, TestClass.TEST_LIST_BASE)

        self.assertEqual(TestClass.TEST_OPERATION_LIST_EQUAL, operations)
예제 #14
0
    def test_operations_returns_empty_with_empty_lists(self):
        operations = get_operations(self.TEST_EMPTY_LIST, self.TEST_EMPTY_LIST)

        self.assertEqual(self.TEST_EMPTY_LIST, operations)