Beispiel #1
0
    def test_diff_histories_added_start(self):
        """Testing diff_histories with a new history that adds commits at the
        start of the history
        """
        old_history = [
            DiffCommit(commit_id='r1'),
            DiffCommit(commit_id='r2'),
        ]

        new_history = [
            DiffCommit(commit_id='r0'),
            DiffCommit(commit_id='r1'),
            DiffCommit(commit_id='r2'),
        ]

        expected_result = [
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_REMOVED,
                old_commit=old_history[0]),
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_REMOVED,
                old_commit=old_history[1]),
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_ADDED,
                new_commit=new_history[0]),
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_ADDED,
                new_commit=new_history[1]),
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_ADDED,
                new_commit=new_history[2]),
        ]

        self.assertEqual(list(diff_histories(old_history, new_history)),
                         expected_result)
Beispiel #2
0
    def test_diff_histories_removed_middle(self):
        """Testing diff_histories with a new history that removes commits in
        the middle of the history
        """
        old_history = [
            DiffCommit(commit_id='r0'),
            DiffCommit(commit_id='r1'),
            DiffCommit(commit_id='r2'),
        ]

        new_history = [
            DiffCommit(commit_id='r0'),
            DiffCommit(commit_id='r2'),
        ]

        expected_result = [
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_UNMODIFIED,
                old_commit=old_history[0],
                new_commit=new_history[0]),
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_REMOVED,
                old_commit=old_history[1]),
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_REMOVED,
                old_commit=old_history[2]),
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_ADDED,
                new_commit=new_history[1]),
        ]

        self.assertEqual(list(diff_histories(old_history, new_history)),
                         expected_result)
Beispiel #3
0
    def test_diff_histories_identical(self):
        """Testing diff_histories with identical histories"""
        new_history = old_history = [
            DiffCommit(commit_id='r0'),
            DiffCommit(commit_id='r1'),
            DiffCommit(commit_id='r2'),
        ]

        expected_result = [
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_UNMODIFIED,
                old_commit=old_history[0],
                new_commit=new_history[0]),
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_UNMODIFIED,
                old_commit=old_history[1],
                new_commit=new_history[1]),
            CommitHistoryDiffEntry(
                entry_type=CommitHistoryDiffEntry.COMMIT_UNMODIFIED,
                old_commit=old_history[2],
                new_commit=new_history[2]),
        ]

        self.assertEqual(list(diff_histories(old_history, new_history)),
                         expected_result)