Example #1
0
    def test_clone_does_not_alter_existing_dirs(self, with_student_repos,
                                                tmpdir):
        """Test that clone does not clobber existing directories."""
        team_with_local_repos = STUDENT_TEAMS[0]
        teams_without_local_repos = STUDENT_TEAMS[1:]

        expected_dir_hashes = []
        for template_repo_name in assignment_names:
            new_dir = plug.fileutils.generate_repo_path(
                str(tmpdir), team_with_local_repos.name, template_repo_name)
            new_dir.mkdir(parents=True)
            new_file = new_dir / "file"
            new_file.write_text(str(new_dir), encoding="utf-8")
            expected_dir_hashes.append((new_dir, hash_directory(new_dir)))
            repobee_testhelpers.funcs.initialize_repo(new_dir)

        command = " ".join([
            *repobee_plug.cli.CoreCommand.repos.clone.as_name_tuple(),
            *BASE_ARGS,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab])

        assert_cloned_repos(teams_without_local_repos, assignment_names,
                            tmpdir)
        for dirpath, expected_hash in expected_dir_hashes:
            dirhash = hash_directory(dirpath)
            assert dirhash == expected_hash, "hash mismatch for " + dirpath
Example #2
0
    def test_discover_repos(self, with_student_repos, tmpdir):
        """Test that the --discover-repos option finds all student repos."""
        command = " ".join([
            *repobee_plug.cli.CoreCommand.repos.clone.as_name_tuple(),
            *BASE_ARGS,
            *STUDENTS_ARG,
            "--discover-repos",
        ])

        run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab])

        assert_cloned_repos(STUDENT_TEAMS, assignment_names, tmpdir)
Example #3
0
    def test_clean_clone(self, with_student_repos, tmpdir):
        """Test cloning student repos when there are no repos in the current
        working directory.
        """
        command = " ".join([
            *repobee_plug.cli.CoreCommand.repos.clone.as_name_tuple(),
            *BASE_ARGS,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab])

        assert_cloned_repos(STUDENT_TEAMS, assignment_names, tmpdir)
Example #4
0
    def test_discover_repos(self, with_student_repos, tmpdir, extra_args):
        """Test that the --discover-repos option finds all student repos."""
        command = " ".join([
            REPOBEE_GITLAB,
            *repobee_plug.cli.CoreCommand.repos.clone.as_name_tuple(),
            *BASE_ARGS,
            *STUDENTS_ARG,
            "--discover-repos",
        ])

        result = run_in_docker_with_coverage(command, extra_args=extra_args)

        assert result.returncode == 0
        assert_cloned_repos(STUDENT_TEAMS, assignment_names, tmpdir)
Example #5
0
    def test_clone_twice(self, with_student_repos, tmpdir):
        """Cloning twice in a row should have the same effect as cloning
        once.
        """
        command = " ".join([
            *repobee_plug.cli.CoreCommand.repos.clone.as_name_tuple(),
            *BASE_ARGS,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab])
        run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab])

        assert_cloned_repos(STUDENT_TEAMS, assignment_names, tmpdir)
Example #6
0
    def test_clean_clone(self, with_student_repos, tmpdir, extra_args):
        """Test cloning student repos when there are no repos in the current
        working directory.
        """
        command = " ".join([
            REPOBEE_GITLAB,
            *repobee_plug.cli.CoreCommand.repos.clone.as_name_tuple(),
            *BASE_ARGS,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        result = run_in_docker_with_coverage(command, extra_args=extra_args)

        assert result.returncode == 0
        assert_cloned_repos(STUDENT_TEAMS, assignment_names, tmpdir)
Example #7
0
    def test_clone_twice(self, with_student_repos, tmpdir, extra_args):
        """Cloning twice in a row should have the same effect as cloning
        once.
        """
        command = " ".join([
            REPOBEE_GITLAB,
            *repobee_plug.cli.CoreCommand.repos.clone.as_name_tuple(),
            *BASE_ARGS,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        first_result = run_in_docker_with_coverage(command,
                                                   extra_args=extra_args)
        second_result = run_in_docker_with_coverage(command,
                                                    extra_args=extra_args)

        assert first_result.returncode == 0
        assert second_result.returncode == 0
        assert_cloned_repos(STUDENT_TEAMS, assignment_names, tmpdir)
Example #8
0
    def test_clone_does_not_alter_existing_dirs(
        self, with_student_repos, tmpdir, extra_args
    ):
        """Test that clone does not clobber existing directories."""
        team_with_local_repos = STUDENT_TEAMS[0]
        teams_without_local_repos = STUDENT_TEAMS[1:]

        expected_dir_hashes = []
        for template_repo_name in assignment_names:
            new_dir = plug.fileutils.generate_repo_path(
                str(tmpdir), team_with_local_repos.name, template_repo_name
            )
            new_dir.mkdir(parents=True)
            new_file = new_dir / "file"
            new_file.write_text(str(new_dir), encoding="utf-8")
            expected_dir_hashes.append((new_dir, hash_directory(new_dir)))

        command = " ".join(
            [
                REPOBEE_GITLAB,
                *repobee_plug.cli.CoreCommand.repos.clone.as_name_tuple(),
                *BASE_ARGS,
                *MASTER_REPOS_ARG,
                *STUDENTS_ARG,
            ]
        )

        result = run_in_docker_with_coverage(command, extra_args=extra_args)

        assert result.returncode == 0
        assert_cloned_repos(
            teams_without_local_repos, assignment_names, tmpdir
        )
        for dirpath, expected_hash in expected_dir_hashes:
            dirhash = hash_directory(dirpath)
            assert dirhash == expected_hash, "hash mismatch for " + dirpath