diff options
Diffstat (limited to 'pygithub3/requests/pull_requests')
-rw-r--r-- | pygithub3/requests/pull_requests/__init__.py | 20 | ||||
-rw-r--r-- | pygithub3/requests/pull_requests/comments.py | 15 |
2 files changed, 20 insertions, 15 deletions
diff --git a/pygithub3/requests/pull_requests/__init__.py b/pygithub3/requests/pull_requests/__init__.py index bd03f3e..f25572d 100644 --- a/pygithub3/requests/pull_requests/__init__.py +++ b/pygithub3/requests/pull_requests/__init__.py @@ -1,5 +1,6 @@ +# -*- encoding: utf-8 -*- + from pygithub3.requests.base import Request, ValidationError -from pygithub3.resources.base import Raw from pygithub3.resources.pull_requests import PullRequest, File from pygithub3.resources.repos import Commit @@ -22,11 +23,12 @@ class Create(Request): 'required': ('base', 'head'), } - def validate_body(self, parsed): - if (not ('title' in parsed and 'body' in parsed) and - not 'issue' in parsed): + def clean_body(self): + if (not ('title' in self.body and 'body' in self.body) and + not 'issue' in self.body): raise ValidationError('pull request creation requires either an ' 'issue number or a title and body') + return self.body class Update(Request): uri = 'repos/{user}/{repo}/pulls/{number}' @@ -36,10 +38,12 @@ class Update(Request): 'required': (), } - def validate_body(self, body): - if 'state' in body and body['state'] not in ['open', 'closed']: + def clean_body(self): + if ('state' in self.body and + self.body['state'] not in ['open', 'closed']): raise ValidationError('If a state is specified, it must be one ' 'of "open" or "closed"') + return self.body class List_commits(Request): @@ -52,14 +56,12 @@ class List_files(Request): resource = File -class Merge_status(Request): +class Is_merged(Request): uri = 'repos/{user}/{repo}/pulls/{number}/merge' - resource = Raw class Merge(Request): uri = 'repos/{user}/{repo}/pulls/{number}/merge' - resource = Raw body_schema = { 'schema': ('commit_message',), 'required': (), diff --git a/pygithub3/requests/pull_requests/comments.py b/pygithub3/requests/pull_requests/comments.py index fa1e5b6..dd69894 100644 --- a/pygithub3/requests/pull_requests/comments.py +++ b/pygithub3/requests/pull_requests/comments.py @@ -1,4 +1,6 @@ -from pygithub3.requests.base import Request +# -*- encoding: utf-8 -*- + +from pygithub3.requests.base import Request, ValidationError from pygithub3.resources.pull_requests import Comment @@ -20,13 +22,14 @@ class Create(Request): 'required': ('body',), } - def validate_body(self, body): - if (not ('commit_id' in body and - 'path' in body and - 'position' in body) and - not 'in_reply_to' in body): + def clean_body(self): + if (not ('commit_id' in self.body and + 'path' in self.body and + 'position' in self.body) and + not 'in_reply_to' in self.body): raise ValidationError('supply either in_reply_to or commit_id, ' 'path, and position') + return self.body class Edit(Request): |