Esempio n. 1
0
    def test_end_double_blind_reviews_when_review_teams_are_missing(
            self, platform_url, with_student_repos):
        """Even if the review teams are missing, the anonymous repos should be
        deleted when running end. Such cases can occurr when there is failure
        in setup, see issue #825 for details.
        """
        # arrange
        assignment_name = const.TEMPLATE_REPO_NAMES[0]
        api = funcs.get_api(platform_url)
        num_repos_before = len(list(api.get_repos()))
        key = 1234

        funcs.run_repobee(f"reviews assign --num-reviews 1 "
                          f"--base-url {platform_url} "
                          f"--double-blind-key {key} "
                          f"--assignments {assignment_name}")

        api._restore_platform_state()
        review_teams = [
            team for team in api.get_teams() if "-" not in team.name
        ]
        for team in review_teams:
            api.delete_team(team)

        # act
        funcs.run_repobee(f"reviews end "
                          f"--base-url {platform_url} "
                          f"--double-blind-key {key} "
                          f"--assignments {assignment_name}")

        # assert
        api._restore_platform_state()
        num_repos_after = len(list(api.get_repos()))
        assert num_repos_after == num_repos_before
Esempio n. 2
0
def setup_student_repos_and_user_accounts(usernames: List[str],
                                          platform_url: str):
    funcs.run_repobee(
        f"repos setup -a {const.TEMPLATE_REPOS_ARG} "
        f"--base-url {platform_url}", )
    api = funcs.get_api(platform_url)
    api._add_users(usernames)
Esempio n. 3
0
    def _setup_empty_task(self, platform_url: str) -> str:
        task_name = "empty-task"
        api = funcs.get_api(platform_url)
        for team in api.get_teams([t.name for t in STUDENT_TEAMS]):
            repo_name = plug.generate_repo_name(team.name, task_name)
            api.create_repo(
                name=repo_name,
                description="An empty task",
                private=True,
                team=team,
            )

        return task_name
Esempio n. 4
0
    def test_double_blind_creates_correct_amount_of_anonymous_copies(
            self, platform_url, with_student_repos):
        assignment_name = const.TEMPLATE_REPO_NAMES[0]
        api = funcs.get_api(platform_url)
        num_repos_before = len(list(api.get_repos()))

        funcs.run_repobee(f"reviews assign --num-reviews 1 "
                          f"--base-url {platform_url} "
                          f"--double-blind-key 1234 "
                          f"--assignments {assignment_name}")

        api._restore_platform_state()
        num_repos_after = len(list(api.get_repos()))
        assert num_repos_after == num_repos_before + len(const.STUDENT_TEAMS)
Esempio n. 5
0
def _setup_double_blind_reviews_with_review_issues(assignment: str, key: str,
                                                   platform_url: str,
                                                   review_title: str) -> None:
    funcs.run_repobee(f"reviews assign --double-blind-key {key} "
                      f"--assignments {assignment} "
                      f"--base-url {platform_url}")
    api = funcs.get_api(platform_url)

    for team in const.STUDENT_TEAMS:
        review_team = _get_anonymous_review_team(team, assignment, key, api)

        student = review_team.members[0]
        anon_repo = next(api.get_team_repos(review_team))
        issue = api.create_issue(review_title, "This is an excellent review",
                                 anon_repo)
        issue.implementation.author = student
Esempio n. 6
0
def platform_dir():
    """Setup the platform emulation with a template organization with git
    repositories, the students and teacher as users,  and return the the
    workdirectory for the platform.
    """
    with tempfile.TemporaryDirectory() as tmpdir:
        template_org_dir = pathlib.Path(tmpdir) / TEMPLATE_ORG_NAME
        shutil.copytree(src=TEMPLATE_REPO_DIR, dst=template_org_dir)
        for template_repo in template_org_dir.iterdir():
            if not template_repo.is_dir():
                continue
            funcs.initialize_repo(template_repo)

        api = funcs.get_api("https://" + str(tmpdir))
        api._add_users(
            itertools.chain.from_iterable([t.members for t in STUDENT_TEAMS]))

        yield pathlib.Path(tmpdir)
Esempio n. 7
0
    def test_setup_with_custom_template_repo(self, platform_dir, platform_url,
                                             tmp_path_factory):
        api = funcs.get_api(platform_url, org_name=const.TEMPLATE_ORG_NAME)

        template_repo = api.create_repo("epIcRepo",
                                        description="dontcare",
                                        private=False)
        local_template_dir = tmp_path_factory.mktemp("template")
        (local_template_dir /
         "file.txt").write_text("this is a brand new file!")

        branch = "master"
        local_template_repo = funcs.initialize_repo(local_template_dir,
                                                    default_branch=branch)
        local_template_repo.git.push(api.insert_auth(template_repo.url),
                                     branch)

        funcs.run_repobee(
            f"repos setup -a {template_repo.name} --base-url {platform_url}")
Esempio n. 8
0
    def test_end_with_allocations_file(
        self,
        platform_url,
        with_student_repos,
        tmp_path,
        activate_review_command_preview,
    ):
        """Test the RepoBee 4 version of `reviews end`, that just takes an
        allocations file.
        """
        # arrange
        workdir = tmp_path / "workdir"
        workdir.mkdir(exist_ok=False)
        alloc_file = workdir / "review_allocations.json"

        funcs.run_repobee(
            f"{plug.cli.CoreCommand.reviews.assign} "
            f"--base-url {platform_url} "
            f"-n 1 "
            f"--assignments {const.TEMPLATE_REPOS_ARG}",
            workdir=workdir,
        )

        # act
        funcs.run_repobee(
            f"{plug.cli.CoreCommand.reviews.end} --base-url {platform_url} "
            f"--allocations-file {alloc_file}",
            workdir=workdir,
        )

        # assert
        api = funcs.get_api(platform_url)
        review_team_names = {
            plug.generate_review_team_name(team, template_repo_name)
            for team in const.STUDENT_TEAMS
            for template_repo_name in const.TEMPLATE_REPO_NAMES
        }

        existing_team_names = {team.name for team in api.get_teams()}
        assert not existing_team_names.intersection(review_team_names)