def test_pr_create_is_not_fork(self, github_project, fork_username): github_project.should_receive("is_fork").and_return(False) GithubPullRequest.should_receive("__init__").and_return() head = ":".join(filter(None, [fork_username, "master"])) github_project.github_repo.should_call("create_pull").with_args( title="test_title", body="test_content", base="master", head=head) github_project.parent.github_repo.should_call("create_pull").never() github_project.github_repo.should_call("create_pull").once() github_project.pr_create( title="test_title", body="test_content", target_branch="master", source_branch="master", fork_username=fork_username, )
def test_pr_create_is_fork(self, github_project, fork_username): github_project.should_receive("is_fork").and_return(True) GithubPullRequest.should_receive("__init__").and_return() github_project.parent.github_repo.should_call("create_pull").with_args( title="test_title", body="test_content", base="master", head=f"{github_project}:master", ) github_project.parent.github_repo.should_call("create_pull").once() github_project.github_repo.should_call("create_pull").never() github_project.pr_create( title="test_title", body="test_content", target_branch="master", source_branch="master", fork_username=fork_username, )
def create_pr( self, title: str, body: str, target_branch: str, source_branch: str, fork_username: str = None, ) -> PullRequest: return GithubPullRequest.create( project=self, title=title, body=body, target_branch=target_branch, source_branch=source_branch, fork_username=fork_username, )
def get_pr(self, pr_id: int) -> PullRequest: return GithubPullRequest.get(project=self, id=pr_id)
def get_pr_list(self, status: PRStatus = PRStatus.open) -> List[PullRequest]: return GithubPullRequest.get_list(project=self, status=status)
def test_wrong_auth_static_method(self): # Verify that the exception handler is applied to static methods with pytest.raises(GithubAPIException): GithubPullRequest.get(self.ogr_project, 1)