Пример #1
0
    def test_result_is_the_parent_directory_of_the_git_diretory(self, get_mock):
        git_dir = os.path.dirname(__file__)
        result = Mock()
        result.git_dir = git_dir

        get_mock.return_value = result

        self.assertEqual(os.path.dirname(git_dir), repo.repo_root())
Пример #2
0
    def test_result_is_the_parent_directory_of_the_git_directory(
            self, get_mock):
        git_dir = os.path.dirname(__file__)
        result = Mock()
        result.git_dir = git_dir

        get_mock.return_value = result

        self.assertEqual(os.path.dirname(git_dir), repo.repo_root())
Пример #3
0
    def test_result_is_untracked_files_from_the_repo_object(self, get_mock):
        git_dir = os.path.dirname(__file__)

        result = Mock()
        result.untracked_files = ['untracked files']
        result.git_dir = git_dir

        get_mock.return_value = result

        files = repo.untracked_files()

        self.assertListEqual([os.path.join(repo.repo_root(), 'untracked files')], files)
Пример #4
0
    def test_result_is_untracked_files_from_the_repo_object(self, get_mock):
        git_dir = os.path.dirname(__file__)

        result = Mock()
        result.untracked_files = ['untracked files']
        result.git_dir = git_dir

        get_mock.return_value = result

        files = repo.untracked_files()

        self.assertListEqual(
            [os.path.join(repo.repo_root(), 'untracked files')], files)
Пример #5
0
    def test_result_is_the_absolute_paths_to_all_new_but_not_modified_or_deleted_files(self, mod, new, deleted):
        mod_diffs = [FakeDiffObject(f, f, False, False) for f in mod]
        new_diffs = [FakeDiffObject(None, f, True, False) for f in new]
        deleted_diffs = [FakeDiffObject(None, f, False, True) for f in deleted]

        with patch('githooks.repo.get') as get_mock:
            git_dir = os.path.dirname(__file__)

            result = Mock()
            result.head.commit.diff = Mock(return_value=mod_diffs + new_diffs + deleted_diffs)
            result.git_dir = git_dir

            get_mock.return_value = result

            files = repo.added_files()

            self.assertEqual([os.path.join(repo.repo_root(), f) for f in new], files)
            result.head.commit.diff.assert_called_once_with()
Пример #6
0
    def test_result_is_the_absolute_paths_to_all_changed_but_not_new_or_deleted_files(
            self, mod, new, deleted):
        mod_diffs = [FakeDiffObject(f, f, False, False) for f in mod]
        new_diffs = [FakeDiffObject(None, f, True, False) for f in new]
        deleted_diffs = [FakeDiffObject(None, f, False, True) for f in deleted]

        with patch('githooks.repo.get') as get_mock:
            git_dir = os.path.dirname(__file__)

            result = Mock()
            result.head.commit.diff = Mock(return_value=mod_diffs + new_diffs +
                                           deleted_diffs)
            result.git_dir = git_dir

            get_mock.return_value = result

            files = repo.modified_files()

            self.assertEqual([os.path.join(repo.repo_root(), f) for f in mod],
                             files)
            result.head.commit.diff.assert_called_once_with()