From 1ae47aa8bea5b42f70e8e8bffb7436d92f89bd55 Mon Sep 17 00:00:00 2001 From: Nate Rubin Date: Thu, 10 Sep 2015 14:18:20 -0400 Subject: [PATCH] Add support for forking to an organization --- libsaas/services/github/forks.py | 10 ++++++++-- test/test_github.py | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libsaas/services/github/forks.py b/libsaas/services/github/forks.py index f6621a0..27c3ba5 100644 --- a/libsaas/services/github/forks.py +++ b/libsaas/services/github/forks.py @@ -32,11 +32,17 @@ def update(self, *args, **kwargs): raise base.MethodNotSupported() @base.apimethod - def create(self): + def create(self, organization=None): """ Fork this repo. + + :var organization: Specify the organization you would + like to fork to. If left as `None` repo will fork + to current user. + :vartype organization: str """ - request = http.Request('POST', self.get_url()) + params = base.get_params(('organization',), locals()) + request = http.Request('POST', self.get_url(), params) return request, parsers.parse_json diff --git a/test/test_github.py b/test/test_github.py index aff0474..ec77d20 100644 --- a/test/test_github.py +++ b/test/test_github.py @@ -424,6 +424,9 @@ def test_forks(self): self.service.repo('myuser', 'myrepo').forks().create() self.expect('POST', '/repos/myuser/myrepo/forks') + self.service.repo('myuser', 'myrepo').forks().create(organization='myorg') + self.expect('POST', '/repos/myuser/myrepo/forks', json.dumps({'organization': 'myorg'})) + def test_users(self): self.service.user().get() self.expect('GET', '/user')