diff options
author | 2012-04-17 18:45:46 +0200 | |
---|---|---|
committer | 2012-04-17 18:45:46 +0200 | |
commit | 8430f64e6f0025b3d3d088ffd13c50b7123972f6 (patch) | |
tree | 214726395e1f0108e757a47d2c0de0ec36a3aeb5 | |
parent | :sparkles: Release 0.3 :sparkles: (diff) | |
parent | add myself to AUTHORS and some other docs tweaks (diff) | |
download | python-github3-8430f64e6f0025b3d3d088ffd13c50b7123972f6.tar.xz python-github3-8430f64e6f0025b3d3d088ffd13c50b7123972f6.zip |
Merged pull request #3 from natw/git_data
-rw-r--r-- | AUTHORS.rst | 6 | ||||
-rw-r--r-- | README.rst | 13 | ||||
-rw-r--r-- | docs/git_data.rst | 86 | ||||
-rw-r--r-- | docs/installation.rst | 14 | ||||
-rw-r--r-- | docs/services.rst | 1 | ||||
-rw-r--r-- | pygithub3/github.py | 9 | ||||
-rw-r--r-- | pygithub3/requests/git_data/__init__.py | 0 | ||||
-rw-r--r-- | pygithub3/requests/git_data/blobs.py | 18 | ||||
-rw-r--r-- | pygithub3/requests/git_data/commits.py | 18 | ||||
-rw-r--r-- | pygithub3/requests/git_data/references.py | 33 | ||||
-rw-r--r-- | pygithub3/requests/git_data/tags.py | 15 | ||||
-rw-r--r-- | pygithub3/requests/git_data/trees.py | 20 | ||||
-rw-r--r-- | pygithub3/resources/gists.py | 1 | ||||
-rw-r--r-- | pygithub3/resources/git_data.py | 28 | ||||
-rw-r--r-- | pygithub3/services/git_data/__init__.py | 20 | ||||
-rw-r--r-- | pygithub3/services/git_data/blobs.py | 32 | ||||
-rw-r--r-- | pygithub3/services/git_data/commits.py | 33 | ||||
-rw-r--r-- | pygithub3/services/git_data/references.py | 77 | ||||
-rw-r--r-- | pygithub3/services/git_data/tags.py | 34 | ||||
-rw-r--r-- | pygithub3/services/git_data/trees.py | 34 | ||||
-rw-r--r-- | pygithub3/tests/services/test_git_data.py | 164 | ||||
-rw-r--r-- | test_requirements.txt | 4 |
22 files changed, 650 insertions, 10 deletions
diff --git a/AUTHORS.rst b/AUTHORS.rst index af05118..4415d5e 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -11,8 +11,9 @@ Forked and redesign from Kenneth Reitz's repo Forked from https://github.com/kennethreitz/python-github3 -Kenneth Reitz is also the author of the awesome `requests <https://github.com/kennethreitz/requests>`_ library -which `python-github3` needs it +Kenneth Reitz is also the author of the awesome +`requests <https://github.com/kennethreitz/requests>`_ library, which +`python-github3` requires. Patches and Suggestions ......................... @@ -21,3 +22,4 @@ Patches and Suggestions - Rok Garbas - Antti Kaihola <akaihol+github@ambitone.com> - Francisco Marcos <fmarcos83@gmail.com> +- Nathaniel Williams <nat.williams@gmail.com> @@ -41,11 +41,12 @@ Achievements - `Users service <http://developer.github.com/v3/users/>`_ - `Repos service <http://developer.github.com/v3/repos/>`_ - `Gists service <http://developer.github.com/v3/gists/>`_ +- `Git Data service <http://developer.github.com/v3/git/>`_ TODO ----- -- Services: Git Data, Issues, Orgs, Pull Requests, Events +- Services: Issues, Orgs, Pull Requests, Events - Oauth authorization API (service?) - Proxy methods into resources (e.g copitux.followers()) @@ -55,8 +56,12 @@ Contribute 1. Fork the `repository <https://github.com/copitux/python-github3>`_ 2. Write a test to cover new feature or to reproduce bug 3. Code with `pep8 <http://www.python.org/dev/peps/pep-0008/>`_ rules -4. Add you to ``AUTHORS`` +4. Add yourself to ``AUTHORS`` 5. Pull request it -**Note**: I use `nose <http://readthedocs.org/docs/nose/en/latest/>`_ test environment, -with `mock <http://www.voidspace.org.uk/python/mock/>`_ ``pip install nose mock`` +Tests +----- + +Test and docs requirements are listed in ``test_requirements.txt``. +Run ``pip install -r test_requirements.txt`` to install them and ``nosetests`` +to run tests. diff --git a/docs/git_data.rst b/docs/git_data.rst new file mode 100644 index 0000000..549420b --- /dev/null +++ b/docs/git_data.rst @@ -0,0 +1,86 @@ +.. _Git Data service: + +Git Data services +================= + +**Example**:: + + from pygithub3 import Github + + gh = Github(user='someone', repo='some_repo') + + a_blob = gh.git_data.blobs.get('a long sha') + + dev_branch = gh.git_data.references.get('heads/add_a_thing') + + +GitData +------- + +.. autoclass:: pygithub3.services.git_data.GitData + :members: + + .. attribute:: blobs + + :ref:`Blobs service` + + .. attribute:: commits + + :ref:`Commits service` + + .. attribute:: references + + :ref:`References service` + + .. attribute:: tags + + :ref:`Tags service` + + .. attribute:: trees + + :ref:`Trees service` + + +.. _Blobs service: + +Blobs +----- + +.. autoclass:: pygithub3.services.git_data.Blobs + :members: + + +.. _Commits service: + +Commits +------- + +.. autoclass:: pygithub3.services.git_data.Commits + :members: + + +.. _References service: + +References +---------- + +.. autoclass:: pygithub3.services.git_data.References + :members: + + +.. _Tags service: + +Tags +---- + +.. autoclass:: pygithub3.services.git_data.Tags + :members: + + +.. _Trees service: + +Trees +----- + +.. autoclass:: pygithub3.services.git_data.Trees + :members: diff --git a/docs/installation.rst b/docs/installation.rst index 8ed6c10..6eccc95 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -15,15 +15,21 @@ Dependencies Required ......... -This library only depends on `request library`_ module. +This library depends only on the `requests`_ module. -If you install ``pygithub3`` with ``pip`` all is done. The best option +If you install ``pygithub3`` with ``pip`` all is done. This is the best option. Optional ......... -If you want to run the test suite, you must install `nose`_ and `mock`_ +The test suite uses `nose`_, `mock`_, and `unittest2`_. Compiling the +documentation requires `sphinx`_. -.. _request library: http://docs.python-requests.org/en/v0.10.6/index.html +Install all of these by running ``pip install -r test_requirements.txt``. Then +just run ``nosetests`` to run the tests. + +.. _requests: http://docs.python-requests.org/en/v0.10.6/index.html .. _nose: http://readthedocs.org/docs/nose/en/latest .. _mock: http://pypi.python.org/pypi/mock +.. _unittest2: http://pypi.python.org/pypi/unittest2 +.. _sphinx: http://sphinx.pocoo.org/ diff --git a/docs/services.rst b/docs/services.rst index 71fa690..2fbd2ee 100644 --- a/docs/services.rst +++ b/docs/services.rst @@ -72,5 +72,6 @@ List of services users repos gists + git_data .. _mimetypes: http://developer.github.com/v3/mime diff --git a/pygithub3/github.py b/pygithub3/github.py index 0b302a1..13829a0 100644 --- a/pygithub3/github.py +++ b/pygithub3/github.py @@ -17,9 +17,11 @@ class Github(object): from pygithub3.services.users import User from pygithub3.services.repos import Repo from pygithub3.services.gists import Gist + from pygithub3.services.git_data import GitData self._users = User(**config) self._repos = Repo(**config) self._gists = Gist(**config) + self._git_data = GitData(**config) @property def remaining_requests(self): @@ -47,3 +49,10 @@ class Github(object): :ref:`Gists service <Gists service>` """ return self._gists + + @property + def git_data(self): + """ + :ref:`Git Data service <Git Data service>` + """ + return self._git_data diff --git a/pygithub3/requests/git_data/__init__.py b/pygithub3/requests/git_data/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/pygithub3/requests/git_data/__init__.py diff --git a/pygithub3/requests/git_data/blobs.py b/pygithub3/requests/git_data/blobs.py new file mode 100644 index 0000000..a4bddd6 --- /dev/null +++ b/pygithub3/requests/git_data/blobs.py @@ -0,0 +1,18 @@ +# -*- encoding: utf-8 -*- + +from pygithub3.requests.base import Request +from pygithub3.resources.git_data import Blob + + +class Get(Request): + uri = 'repos/{user}/{repo}/git/blobs/{sha}' + resource = Blob + + +class Create(Request): + uri = 'repos/{user}/{repo}/git/blobs' + resource = Blob + body_schema = { + 'schema': ('content', 'encoding'), + 'required': ('content', 'encoding'), # TODO: is enc really required? + } diff --git a/pygithub3/requests/git_data/commits.py b/pygithub3/requests/git_data/commits.py new file mode 100644 index 0000000..caf1e7d --- /dev/null +++ b/pygithub3/requests/git_data/commits.py @@ -0,0 +1,18 @@ +# -*- encoding: utf-8 -*- + +from pygithub3.requests.base import Request +from pygithub3.resources.git_data import Commit + + +class Get(Request): + uri = 'repos/{user}/{repo}/git/commits/{sha}' + resource = Commit + + +class Create(Request): + uri = 'repos/{user}/{repo}/git/commits' + resource = Commit + body_schema = { + 'schema': ('message', 'tree', 'parents', 'author', 'committer'), + 'required': ('message', 'tree', 'parents'), + } diff --git a/pygithub3/requests/git_data/references.py b/pygithub3/requests/git_data/references.py new file mode 100644 index 0000000..99cf41a --- /dev/null +++ b/pygithub3/requests/git_data/references.py @@ -0,0 +1,33 @@ +from pygithub3.requests.base import Request +from pygithub3.resources.git_data import Reference + + +class Get(Request): + uri = 'repos/{user}/{repo}/git/refs/{ref}' + resource = Reference + + +class List(Request): + uri = 'repos/{user}/{repo}/git/refs' + resource = Reference + + +class Create(Request): + uri = 'repos/{user}/{repo}/git/refs' + resource = Reference + body_schema = { + 'schema': ('ref', 'sha'), + 'required': ('ref', 'sha'), + } + +class Update(Request): + uri = 'repos/{user}/{repo}/git/refs/{ref}' + resource = Reference + body_schema = { + 'schema': ('sha', 'force'), + 'required': ('sha',), + } + + +class Delete(Request): + uri = 'repos/{user}/{repo}/git/refs/{ref}' diff --git a/pygithub3/requests/git_data/tags.py b/pygithub3/requests/git_data/tags.py new file mode 100644 index 0000000..dbc8da4 --- /dev/null +++ b/pygithub3/requests/git_data/tags.py @@ -0,0 +1,15 @@ +from pygithub3.requests.base import Request +from pygithub3.resources.git_data import Tag + + +class Get(Request): + uri = 'repos/{user}/{repo}/git/tags/{sha}' + resource = Tag + +class Create(Request): + uri = 'repos/{user}/{repo}/git/tags' + resource = Tag + body_schema = { + 'schema': ('tag', 'message', 'object', 'type', 'tagger'), + 'required': ('type',), + } diff --git a/pygithub3/requests/git_data/trees.py b/pygithub3/requests/git_data/trees.py new file mode 100644 index 0000000..bd1593f --- /dev/null +++ b/pygithub3/requests/git_data/trees.py @@ -0,0 +1,20 @@ +from pygithub3.requests.base import Request +from pygithub3.resources.git_data import Tree + + +class Get(Request): + uri = 'repos/{user}/{repo}/git/trees/{sha}' + resource = Tree + + def clean_uri(self): + if self.recursive: + return self.uri + '?recursive=1' + + +class Create(Request): + uri = 'repos/{user}/{repo}/git/trees' + resource = Tree + body_schema = { + 'schema': ('tree',), + 'required': ('tree',), + } diff --git a/pygithub3/resources/gists.py b/pygithub3/resources/gists.py index 7e9550a..89425bf 100644 --- a/pygithub3/resources/gists.py +++ b/pygithub3/resources/gists.py @@ -15,6 +15,7 @@ class Fork(Resource): _dates = ('created_at', ) _maps = {'user': User} + def __str__(self): return '<GistFork>' diff --git a/pygithub3/resources/git_data.py b/pygithub3/resources/git_data.py new file mode 100644 index 0000000..4d12e01 --- /dev/null +++ b/pygithub3/resources/git_data.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from .base import Resource +from .repos import Author, Commit + + +class Blob(Resource): + def __str__(self): + return "<Blob (%s)>" % getattr(self, 'content', '') + + +class Reference(Resource): + def __str__(self): + return '<Reference (%s)>' % getattr(self, 'ref', '') + + +class Tag(Resource): + _maps = {'object': Commit, + 'tagger': Author} # committer? tagger? + + def __str__(self): + return '<Tag (%s)>' % getattr(self, 'tag', '') + + +class Tree(Resource): + def __str__(self): + return '<Tree (%s)>' % getattr(self, 'sha', '') diff --git a/pygithub3/services/git_data/__init__.py b/pygithub3/services/git_data/__init__.py new file mode 100644 index 0000000..4a3ff9f --- /dev/null +++ b/pygithub3/services/git_data/__init__.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from pygithub3.services.base import Service +from .blobs import Blobs +from .commits import Commits +from .references import References +from .tags import Tags +from .trees import Trees + +class GitData(Service): + """Consume `Git Data API <http://developer.github.com/v3/git/>`_""" + + def __init__(self, **config): + self.blobs = Blobs(**config) + self.commits = Commits(**config) + self.references = References(**config) + self.tags = Tags(**config) + self.trees = Trees(**config) + super(GitData, self).__init__(**config) diff --git a/pygithub3/services/git_data/blobs.py b/pygithub3/services/git_data/blobs.py new file mode 100644 index 0000000..4f1a6e7 --- /dev/null +++ b/pygithub3/services/git_data/blobs.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from pygithub3.services.base import Service + + +class Blobs(Service): + """Consume `Blobs API <http://developer.github.com/v3/git/blobs/>`_""" + + def get(self, sha, user=None, repo=None): + """Get a particular blob + + :param str sha: The sha of the blob to get + :param str user: Username + :param str repo: Repository + + """ + request = self.make_request('git_data.blobs.get', sha=sha, + user=user, repo=repo) + return self._get(request) + + def create(self, data, user=None, repo=None): + """Create a blob + + :param dict data: Data describing the blob to create + :param str user: Username + :param str repo: Repository + + """ + request = self.make_request('git_data.blobs.create', body=data, + user=user, repo=repo) + return self._post(request) diff --git a/pygithub3/services/git_data/commits.py b/pygithub3/services/git_data/commits.py new file mode 100644 index 0000000..25e8775 --- /dev/null +++ b/pygithub3/services/git_data/commits.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from pygithub3.services.base import Service + + +class Commits(Service): + """Consume `Commits API <http://developer.github.com/v3/git/commits/>`_""" + + def get(self, sha, user=None, repo=None): + """get a commit from the current repo + + :param str sha: SHA of the Commit that you want. + :param str user: Username + :param str repo: Repository + + """ + request = self.make_request('git_data.commits.get', sha=sha, + user=user, repo=repo) + return self._get(request) + + def create(self, data, user=None, repo=None): + """create a commit on a repo + + :param dict data: Input. See `github commits doc`_ + :param str user: username + :param str repo: repository name + + """ + return self._post( + self.make_request('git_data.commits.create', user=user, repo=repo, + body=data) + ) diff --git a/pygithub3/services/git_data/references.py b/pygithub3/services/git_data/references.py new file mode 100644 index 0000000..3a24f90 --- /dev/null +++ b/pygithub3/services/git_data/references.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from pygithub3.services.base import Service + + +class References(Service): + """Consume `References API <http://developer.github.com/v3/git/refs/>`_""" + + def get(self, ref, user=None, repo=None): + """Get a reference. + + .. note:: + Remember that branch references look like "heads/<branch_name>" + + :param str ref: the name of the reference to get + :param str user: Username + :param str repo: Repository + + """ + return self._get( + self.make_request('git_data.references.get', ref=ref, user=user, + repo=repo) + ) + + def list(self, namespace='', user=None, repo=None): + """List all the references + + :param str namespace: Limit the request to a particular type of + reference. For example, ``heads`` or ``tags``. + :param str user: Username + :param str repo: Repository + + """ + return self._get( + self.make_request('git_data.references.list', user=user, repo=repo) + ) + + def create(self, body, user=None, repo=None): + """Create a reference + + :param dict body: Data describing the reference to create + :param str user: Username + :param str repo: Repository + + """ + return self._post( + self.make_request('git_data.references.create', body=body, + user=user, repo=repo) + ) + + def update(self, ref, body, user=None, repo=None): + """Update an existing reference + + :param str ref: The SHA of the reference to update + :param dict body: Data to update the reference with + :param str user: Username + :param str repo: Repository + + """ + return self._patch( + self.make_request('git_data.references.update', ref=ref, body=body, + user=user, repo=repo) + ) + + def delete(self, ref, user=None, repo=None): + """Delete a reference + + :param str ref: The SHA of the reference to delete + :param str user: Username + :param str repo: Repository + + """ + return self._delete( + self.make_request('git_data.references.delete', ref=ref, user=user, + repo=repo) + ) diff --git a/pygithub3/services/git_data/tags.py b/pygithub3/services/git_data/tags.py new file mode 100644 index 0000000..03d38ac --- /dev/null +++ b/pygithub3/services/git_data/tags.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from pygithub3.services.base import Service + + +class Tags(Service): + """Consume `Tags API <http://developer.github.com/v3/git/tags/>`_""" + + def get(self, sha, user=None, repo=None): + """Get a tag + + :param str sha: The sha of the tag to get. + :param str user: Username + :param str repo: Repository + + """ + return self._get( + self.make_request('git_data.tags.get', sha=sha, user=user, + repo=repo) + ) + + def create(self, body, user=None, repo=None): + """Create a tag + + :param dict body: Data describing the tag to create + :param str user: Username + :param str repo: Repository + + """ + return self._post( + self.make_request('git_data.tags.create', body=body, user=user, + repo=repo) + ) diff --git a/pygithub3/services/git_data/trees.py b/pygithub3/services/git_data/trees.py new file mode 100644 index 0000000..00e010b --- /dev/null +++ b/pygithub3/services/git_data/trees.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from pygithub3.services.base import Service + + +class Trees(Service): + """Consume `Trees API <http://developer.github.com/v3/git/trees/>`_""" + + def get(self, sha, recursive=False, user=None, repo=None): + """Get a tree object + + :param str sha: The SHA of the tree you want. + :param bool recursive: Whether to resolve each sub-tree belonging to + this tree + :param str user: Username + :param str repo: Repository + + """ + return self._get( + self.make_request('git_data.trees.get', sha=sha, + recursive=recursive, user=user, repo=repo) + ) + + def create(self, body, user=None, repo=None): + """Create a tree object + + :param dict body: Data describing the tree to create + + """ + return self._post( + self.make_request('git_data.trees.create', body=body, user=user, + repo=repo) + ) diff --git a/pygithub3/tests/services/test_git_data.py b/pygithub3/tests/services/test_git_data.py new file mode 100644 index 0000000..45ef6d1 --- /dev/null +++ b/pygithub3/tests/services/test_git_data.py @@ -0,0 +1,164 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +import requests +from mock import patch, Mock + +from pygithub3.tests.utils.core import TestCase +from pygithub3.services.git_data import (Blobs, Commits, References, Tags, + Trees) +from pygithub3.resources.base import json +from pygithub3.tests.utils.base import (mock_response, mock_response_result, + mock_json) +from pygithub3.tests.utils.services import _ + + +json.dumps = Mock(side_effect=mock_json) +json.loads = Mock(side_effect=mock_json) + + +@patch.object(requests.sessions.Session, 'request') +class TestBlobsService(TestCase): + def setUp(self): + self.service = Blobs(user='octocat', repo='repo') + + def test_GET(self, reqm): + reqm.return_value = mock_response() + self.service.get('abc123') + self.assertEqual(reqm.call_args[0], + ('get', _('repos/octocat/repo/git/blobs/abc123'))) + + def test_CREATE(self, reqm): + reqm.return_value = mock_response('post') + self.service.create({'content': 'hello, friends', 'encoding': + 'utf-8'}) + self.assertEqual(reqm.call_args[0], + ('post', _('repos/octocat/repo/git/blobs'))) + + +@patch.object(requests.sessions.Session, 'request') +class TestCommitsService(TestCase): + def setUp(self): + self.service = Commits(user='octocat', repo='repo') + + def test_GET(self, reqm): + reqm.return_value = mock_response() + self.service.get('abc123') + self.assertEqual( + reqm.call_args[0], + ('get', _('repos/octocat/repo/git/commits/abc123')) + ) + + def test_CREATE(self, reqm): + reqm.return_value = mock_response('post') + self.service.create({ + 'message': 'hello', + 'tree': 'abc123', + 'parents': ['mom', 'dad'], + }) + self.assertEqual( + reqm.call_args[0], + ('post', _('repos/octocat/repo/git/commits')) + ) + +@patch.object(requests.sessions.Session, 'request') +class TestReferencesService(TestCase): + def setUp(self): + self.service = References(user='user', repo='repo') + + def test_GET(self, reqm): + reqm.return_value = mock_response() + self.service.get('heads/fnord') + self.assertEqual( + reqm.call_args[0], + ('get', _('repos/user/repo/git/refs/heads/fnord')) + ) + + def test_LIST(self, reqm): + reqm.return_value = mock_response() + self.service.list() + self.assertEqual( + reqm.call_args[0], + ('get', _('repos/user/repo/git/refs')) + ) + + def test_create(self, reqm): + reqm.return_value = mock_response('post') + self.service.create({'sha': 'hello', 'ref': 'something'}) + self.assertEqual( + reqm.call_args[0], + ('post', _('repos/user/repo/git/refs')) + ) + + def test_update(self, reqm): + reqm.return_value = mock_response('patch') + self.service.update('master', {'sha': 'abc123'}) + self.assertEqual( + reqm.call_args[0], + ('patch', _('repos/user/repo/git/refs/master')) + ) + + def test_delete(self, reqm): + reqm.return_value = mock_response('delete') + self.service.delete('branch') + self.assertEqual( + reqm.call_args[0], + ('delete', _('repos/user/repo/git/refs/branch')) + ) + +@patch.object(requests.sessions.Session, 'request') +class TestTagsService(TestCase): + def setUp(self): + self.service = Tags(user='user', repo='repo') + + def test_GET(self, reqm): + reqm.return_value = mock_response() + self.service.get('abc123') + self.assertEqual( + reqm.call_args[0], + ('get', _('repos/user/repo/git/tags/abc123')) + ) + + def test_CREATE(self, reqm): + reqm.return_value = mock_response('post') + self.service.create({'tag': 'v1.2.3', 'message': 'a tag', + 'object': 'abc123', 'type': 'commit'}) + self.assertEqual( + reqm.call_args[0], + ('post', _('repos/user/repo/git/tags')) + ) + + +@patch.object(requests.sessions.Session, 'request') +class TestTreesService(TestCase): + def setUp(self): + self.service = Trees(user='user', repo='repo') + + def test_GET(self, reqm): + reqm.return_value = mock_response() + self.service.get('abc123') + self.assertEqual( + reqm.call_args[0], + ('get', _('repos/user/repo/git/trees/abc123')) + ) + + def test_GET_recursive(self, reqm): + reqm.return_value = mock_response() + self.service.get('abc123', recursive=True) + self.assertEqual( + reqm.call_args[0], + ('get', _('repos/user/repo/git/trees/abc123?recursive=1')) + ) + + def test_CREATE(self, reqm): + reqm.return_value = mock_response('post') + self.service.create({ + 'tree': [ + {'path': 'foo.txt', 'mode': '100644', 'type': 'blob', + 'sha': 'abc123'}, + ], + }) + self.assertEqual( + reqm.call_args[0], + ('post', _('repos/user/repo/git/trees')) + ) diff --git a/test_requirements.txt b/test_requirements.txt new file mode 100644 index 0000000..862d240 --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1,4 @@ +nose +unittest2 +mock +sphinx |