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, )
def test_opens_issue_if_update_rejected(self, tmpdir, with_student_repos): master_repo = assignment_names[0] conflict_repo = plug.generate_repo_name(STUDENT_TEAMS[0], master_repo) filename = "superfile.super" text = "some epic content\nfor this file!" # update the master repo update_repo(master_repo, filename, text) # conflicting update in the student repo update_repo(conflict_repo, "somefile.txt", "some other content") issue = plug.Issue(title="Oops, push was rejected!", body="") issue_file = pathlib.Path(str(tmpdir)) / "issue.md" issue_file.write_text(issue.title) command = " ".join([ *repobee_plug.cli.CoreCommand.repos.update.as_name_tuple(), *TEMPLATE_ORG_ARG, *BASE_ARGS, "-a", master_repo, *STUDENTS_ARG, "--issue", issue_file.name, ]) run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab]) assert_repos_contain(STUDENT_TEAMS[1:], [master_repo], filename, text) assert_issues_exist(STUDENT_TEAMS[0:1], [master_repo], issue)
def test_closes_only_matched_issues(self, open_issues, tmpdir): """Test that close-issues respects the regex.""" assert len(open_issues) == 2, "expected there to be only 2 open issues" close_issue = open_issues[0] open_issue = open_issues[1] command = " ".join([ *repobee_plug.cli.CoreCommand.issues.close.as_name_tuple(), *BASE_ARGS, *MASTER_REPOS_ARG, *STUDENTS_ARG, "-r", close_issue.title, ]) run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab]) assert_issues_exist( STUDENT_TEAM_NAMES, assignment_names, close_issue, expected_state="closed", ) assert_issues_exist( STUDENT_TEAM_NAMES, assignment_names, open_issue, expected_state="opened", )
def test_closes_only_matched_issues(self, open_issues, extra_args): """Test that close-issues respects the regex.""" assert len(open_issues) == 2, "expected there to be only 2 open issues" close_issue = open_issues[0] open_issue = open_issues[1] command = " ".join( [ REPOBEE_GITLAB, *repobee_plug.cli.CoreCommand.issues.close.as_name_tuple(), *BASE_ARGS, *MASTER_REPOS_ARG, *STUDENTS_ARG, "-r", close_issue.title, ] ) result = run_in_docker_with_coverage(command, extra_args=extra_args) assert result.returncode == 0 assert_issues_exist( STUDENT_TEAM_NAMES, assignment_names, close_issue, expected_state="closed", ) assert_issues_exist( STUDENT_TEAM_NAMES, assignment_names, open_issue, expected_state="opened", )
def open_issues(with_student_repos): """Open two issues in each student repo.""" task_issue = plug.Issue( title="Task", body="The task is to do this, this and that" ) correction_issue = plug.Issue( title="Correction required", body="You need to fix this, this and that" ) issues = [task_issue, correction_issue] gl = gitlab.Gitlab(LOCAL_BASE_URL, private_token=TOKEN, ssl_verify=False) target_group = get_group(ORG_NAME, gl=gl) projects = ( gl.projects.get(p.id) for p in target_group.projects.list(include_subgroups=True, all=True) ) for project in projects: project.issues.create( dict(title=task_issue.title, description=task_issue.body) ) project.issues.create( dict( title=correction_issue.title, description=correction_issue.body ) ) assert_num_issues(STUDENT_TEAM_NAMES, assignment_names, len(issues)) assert_issues_exist(STUDENT_TEAM_NAMES, assignment_names, task_issue) assert_issues_exist(STUDENT_TEAM_NAMES, assignment_names, correction_issue) return issues
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, )
def test_happy_path(self, tmpdir): """Test opening an issue in each student repo.""" filename = "issue.md" text = "{}\n{}".format(self._ISSUE.title, self._ISSUE.body) tmpdir.join(filename).write_text(text, encoding="utf-8") command = " ".join([ *repobee_plug.cli.CoreCommand.issues.open.as_name_tuple(), *BASE_ARGS, *MASTER_REPOS_ARG, *STUDENTS_ARG, "-i", f"{tmpdir}/{filename}", ]) run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab]) assert_num_issues(STUDENT_TEAMS, assignment_names, 1) assert_issues_exist(STUDENT_TEAMS, assignment_names, self._ISSUE)
def test_happy_path(self, tmpdir_volume_arg, tmpdir, extra_args): """Test opening an issue in each student repo.""" filename = "issue.md" text = "{}\n{}".format(self._ISSUE.title, self._ISSUE.body) tmpdir.join(filename).write_text(text, encoding="utf-8") command = " ".join([ REPOBEE_GITLAB, *repobee_plug.cli.CoreCommand.issues.open.as_name_tuple(), *BASE_ARGS, *MASTER_REPOS_ARG, *STUDENTS_ARG, "-i", "{}/{}".format(VOLUME_DST, filename), ]) result = run_in_docker_with_coverage(command, extra_args=extra_args) assert result.returncode == 0 assert_num_issues(STUDENT_TEAMS, assignment_names, 1) assert_issues_exist(STUDENT_TEAMS, assignment_names, self._ISSUE)