diff options
| author | 2012-05-12 19:04:23 +0200 | |
|---|---|---|
| committer | 2012-05-12 22:47:09 +0200 | |
| commit | 24a3ed5dcd2264a64e234ea7bd526049fafe7616 (patch) | |
| tree | 6131f221a9bf9b596dc139715d4e79f090bb55c3 /pygithub3/requests/pull_requests/__init__.py | |
| parent | Deleted 'dispatch' decorator. No sense (diff) | |
| download | python-github3-24a3ed5dcd2264a64e234ea7bd526049fafe7616.tar.xz python-github3-24a3ed5dcd2264a64e234ea7bd526049fafe7616.zip | |
Some fixes/typos and 'validate_body' related
Diffstat (limited to 'pygithub3/requests/pull_requests/__init__.py')
| -rw-r--r-- | pygithub3/requests/pull_requests/__init__.py | 20 |
1 files changed, 11 insertions, 9 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': (), |
