Ejemplo n.º 1
0
    def test_assign_one_review(self, with_student_repos, tmpdir):
        assignment_name = assignment_names[1]
        expected_review_teams = [
            plug.StudentTeam(
                members=[],
                name=plug.generate_review_team_name(student_team_name,
                                                    assignment_name),
            ) for student_team_name in STUDENT_TEAM_NAMES
        ]
        command = " ".join([
            *repobee_plug.cli.CoreCommand.reviews.assign.as_name_tuple(),
            *BASE_ARGS,
            "-a",
            assignment_name,
            *STUDENTS_ARG,
            "-n",
            "1",
        ])
        group_assertion = expected_num_members_group_assertion(
            expected_num_members=1)

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

        assert_on_groups(expected_review_teams,
                         single_group_assertion=group_assertion)
        assert_num_issues(STUDENT_TEAMS, [assignment_name], 1)
        assert_issues_exist(
            STUDENT_TEAMS,
            [assignment_name],
            _repobee.command.peer.DEFAULT_REVIEW_ISSUE,
            expected_num_asignees=1,
        )
Ejemplo n.º 2
0
def with_reviews(with_student_repos):
    assignment_name = assignment_names[1]
    expected_review_teams = [
        plug.StudentTeam(
            members=[],
            name=plug.generate_review_team_name(
                student_team_name, assignment_name
            ),
        )
        for student_team_name in STUDENT_TEAM_NAMES
    ]
    command = " ".join(
        [
            REPOBEE_GITLAB,
            *str(repobee_plug.cli.CoreCommand.reviews.assign).split(),
            *BASE_ARGS,
            "-a",
            assignment_name,
            *STUDENTS_ARG,
            "-n",
            "1",
        ]
    )

    result = run_in_docker(command)

    assert result.returncode == 0
    assert_on_groups(
        expected_review_teams,
        single_group_assertion=expected_num_members_group_assertion(1),
    )
    return (assignment_name, expected_review_teams)
Ejemplo n.º 3
0
    def test_end_all_reviews(self, with_reviews, extra_args):
        assignment_name, review_teams = with_reviews
        command = " ".join(
            [
                REPOBEE_GITLAB,
                *repobee_plug.cli.CoreCommand.reviews.end.as_name_tuple(),
                *BASE_ARGS,
                "-a",
                assignment_name,
                *STUDENTS_ARG,
            ]
        )

        result = run_in_docker_with_coverage(command, extra_args=extra_args)

        def assert_no_actual_groups(expected, actual):
            assert not actual

        assert result.returncode == 0
        # student teams should still exist
        assert_on_groups(STUDENT_TEAMS)
        # review teams should not
        assert_on_groups(
            review_teams, all_groups_assertion=assert_no_actual_groups
        )
Ejemplo n.º 4
0
    def test_assign_one_review(self, with_student_repos, extra_args):
        assignment_name = assignment_names[1]
        expected_review_teams = [
            plug.StudentTeam(
                members=[],
                name=plug.generate_review_team_name(student_team_name,
                                                    assignment_name),
            ) for student_team_name in STUDENT_TEAM_NAMES
        ]
        command = " ".join([
            REPOBEE_GITLAB,
            *repobee_plug.cli.CoreCommand.reviews.assign.as_name_tuple(),
            *BASE_ARGS,
            "-a",
            assignment_name,
            *STUDENTS_ARG,
            "-n",
            "1",
        ])
        group_assertion = expected_num_members_group_assertion(
            expected_num_members=1)

        result = run_in_docker_with_coverage(command, extra_args=extra_args)

        assert result.returncode == 0
        assert_on_groups(expected_review_teams,
                         single_group_assertion=group_assertion)
        assert_num_issues(STUDENT_TEAMS, [assignment_name], 1)
        assert_issues_exist(
            STUDENT_TEAMS,
            [assignment_name],
            _repobee.command.peer.DEFAULT_REVIEW_ISSUE,
            expected_num_asignees=1,
        )
Ejemplo n.º 5
0
def with_reviews(with_student_repos, tmpdir):
    assignment_name = assignment_names[1]
    expected_review_teams = [
        plug.StudentTeam(
            members=[],
            name=plug.generate_review_team_name(student_team_name,
                                                assignment_name),
        ) for student_team_name in STUDENT_TEAM_NAMES
    ]
    command = " ".join([
        *str(repobee_plug.cli.CoreCommand.reviews.assign).split(),
        *BASE_ARGS,
        "-a",
        assignment_name,
        *STUDENTS_ARG,
        "-n",
        "1",
    ])

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

    assert_on_groups(
        expected_review_teams,
        single_group_assertion=expected_num_members_group_assertion(1),
    )
    return (assignment_name, expected_review_teams)
Ejemplo n.º 6
0
    def test_clean_setup(self, tmpdir):
        """Test a first-time setup with master repos in the master org."""
        command = " ".join([
            *repobee_plug.cli.CoreCommand.repos.setup.as_name_tuple(),
            *BASE_ARGS,
            *TEMPLATE_ORG_ARG,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab])
        assert_repos_exist(STUDENT_TEAMS, assignment_names)
        assert_on_groups(STUDENT_TEAMS)
Ejemplo n.º 7
0
    def test_setup_twice(self, tmpdir):
        """Setting up twice should have the same effect as setting up once."""
        command = " ".join([
            *repobee_plug.cli.CoreCommand.repos.setup.as_name_tuple(),
            *BASE_ARGS,
            *TEMPLATE_ORG_ARG,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab])
        run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab])
        assert_repos_exist(STUDENT_TEAMS, assignment_names)
        assert_on_groups(STUDENT_TEAMS)
Ejemplo n.º 8
0
    def test_clean_setup(self, extra_args):
        """Test a first-time setup with master repos in the master org."""
        command = " ".join([
            REPOBEE_GITLAB,
            *repobee_plug.cli.CoreCommand.repos.setup.as_name_tuple(),
            *BASE_ARGS,
            *TEMPLATE_ORG_ARG,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        result = run_in_docker_with_coverage(command, extra_args=extra_args)
        assert result.returncode == 0
        assert_repos_exist(STUDENT_TEAMS, assignment_names)
        assert_on_groups(STUDENT_TEAMS)
Ejemplo n.º 9
0
    def test_setup_twice(self, extra_args):
        """Setting up twice should have the same effect as setting up once."""
        command = " ".join([
            REPOBEE_GITLAB,
            *repobee_plug.cli.CoreCommand.repos.setup.as_name_tuple(),
            *BASE_ARGS,
            *TEMPLATE_ORG_ARG,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        result = run_in_docker_with_coverage(command, extra_args=extra_args)
        result = run_in_docker_with_coverage(command, extra_args=extra_args)
        assert result.returncode == 0
        assert_repos_exist(STUDENT_TEAMS, assignment_names)
        assert_on_groups(STUDENT_TEAMS)
Ejemplo n.º 10
0
    def test_end_non_existing_reviews(self, with_reviews, tmpdir):
        _, review_teams = with_reviews
        assignment_name = assignment_names[0]
        command = " ".join([
            *repobee_plug.cli.CoreCommand.reviews.end.as_name_tuple(),
            *BASE_ARGS,
            "-a",
            assignment_name,
            *STUDENTS_ARG,
        ])

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

        assert_on_groups(STUDENT_TEAMS)
        assert_on_groups(
            review_teams,
            single_group_assertion=expected_num_members_group_assertion(1),
        )
Ejemplo n.º 11
0
    def test_end_all_reviews(self, with_reviews, tmpdir):
        assignment_name, review_teams = with_reviews
        command = " ".join([
            *repobee_plug.cli.CoreCommand.reviews.end.as_name_tuple(),
            *BASE_ARGS,
            "-a",
            assignment_name,
            *STUDENTS_ARG,
        ])

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

        def assert_no_actual_groups(expected, actual):
            assert not actual

        # student teams should still exist
        assert_on_groups(STUDENT_TEAMS)
        # review teams should not
        assert_on_groups(review_teams,
                         all_groups_assertion=assert_no_actual_groups)
Ejemplo n.º 12
0
    def test_end_non_existing_reviews(self, with_reviews, extra_args):
        _, review_teams = with_reviews
        assignment_name = assignment_names[0]
        command = " ".join([
            REPOBEE_GITLAB,
            *repobee_plug.cli.CoreCommand.reviews.end.as_name_tuple(),
            *BASE_ARGS,
            "-a",
            assignment_name,
            *STUDENTS_ARG,
        ])

        result = run_in_docker_with_coverage(command, extra_args=extra_args)

        assert result.returncode == 0
        assert_on_groups(STUDENT_TEAMS)
        assert_on_groups(
            review_teams,
            single_group_assertion=expected_num_members_group_assertion(1),
        )
Ejemplo n.º 13
0
def with_student_repos(restore):
    """Set up student repos before starting tests.

    Note that explicitly including restore here is necessary to ensure that
    it runs before this fixture.
    """
    command = " ".join([
        REPOBEE_GITLAB,
        *str(repobee_plug.cli.CoreCommand.repos.setup).split(),
        *BASE_ARGS,
        *TEMPLATE_ORG_ARG,
        *MASTER_REPOS_ARG,
        *STUDENTS_ARG,
    ])

    result = run_in_docker(command)

    # pre-test asserts
    assert result.returncode == 0
    assert_repos_exist(STUDENT_TEAMS, assignment_names)
    assert_on_groups(STUDENT_TEAMS)
Ejemplo n.º 14
0
def with_student_repos(restore, tmpdir):
    """Set up student repos before starting tests.

    Note that explicitly including restore here is necessary to ensure that
    it runs before this fixture.
    """
    command = " ".join([
        *str(repobee_plug.cli.CoreCommand.repos.setup).split(),
        *BASE_ARGS,
        *TEMPLATE_ORG_ARG,
        *MASTER_REPOS_ARG,
        *STUDENTS_ARG,
    ])

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

    # pre-test asserts
    assert_repos_exist(STUDENT_TEAMS, assignment_names)
    assert_on_groups(STUDENT_TEAMS)