예제 #1
0
 def __init__(self, **config):
     from pygithub3.services.users import User
     from pygithub3.services.repos import Repo
     from pygithub3.services.gists import Gist
     self._users = User(**config)
     self._repos = Repo(**config)
     self._gists = Gist(**config)
예제 #2
0
 def __init__(self, **config):
     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
     from pygithub3.services.pull_requests import PullRequests
     from pygithub3.services.orgs import Org
     from pygithub3.services.issues import Issue
     self._users = User(**config)
     self._repos = Repo(**config)
     self._gists = Gist(**config)
     self._git_data = GitData(**config)
     self._pull_requests = PullRequests(**config)
     self._orgs = Org(**config)
     self._issues = Issue(**config)
예제 #3
0
파일: test_gists.py 프로젝트: tirimula/ITSP
 def setUp(self):
     self.gs = Gist()
예제 #4
0
파일: test_gists.py 프로젝트: tirimula/ITSP
class TestGistService(TestCase):
    def setUp(self):
        self.gs = Gist()

    def test_LIST_without_user(self, request_method):
        request_method.return_value = mock_response_result()
        self.gs.list().all()
        self.assertEqual(request_method.call_args[0], ('get', _('gists')))

    def test_LIST_with_user(self, request_method):
        request_method.return_value = mock_response_result()
        self.gs.list('octocat').all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('users/octocat/gists')))

    def test_LIST_public(self, request_method):
        request_method.return_value = mock_response_result()
        self.gs.public().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('gists/public')))

    def test_LIST_starred(self, request_method):
        request_method.return_value = mock_response_result()
        self.gs.starred().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('gists/starred')))

    def test_GET(self, request_method):
        request_method.return_value = mock_response()
        self.gs.get(1)
        self.assertEqual(request_method.call_args[0], ('get', _('gists/1')))

    def test_CREATE(self, request_method):
        request_method.return_value = mock_response('post')
        self.gs.create(
            dict(public=True,
                 files={'file1.txt': {
                     'content': 'Some\ncontent'
                 }}))
        self.assertEqual(request_method.call_args[0], ('post', _('gists')))

    def test_UPDATE(self, request_method):
        request_method.return_value = mock_response('patch')
        self.gs.update(1, {'description': 'edited'})
        self.assertEqual(request_method.call_args[0], ('patch', _('gists/1')))

    def test_STAR(self, request_method):
        self.gs.star(1)
        self.assertEqual(request_method.call_args[0],
                         ('put', _('gists/1/star')))

    def test_UNSTAR(self, request_method):
        request_method.return_value = mock_response('delete')
        self.gs.unstar(1)
        self.assertEqual(request_method.call_args[0],
                         ('delete', _('gists/1/star')))

    def test_IS_STARRED(self, request_method):
        request_method.return_value = mock_response()
        self.gs.is_starred(1)
        self.assertEqual(request_method.call_args[0],
                         ('head', _('gists/1/star')))

    def test_FORK(self, request_method):
        request_method.return_value = mock_response('post')
        self.gs.fork(1)
        self.assertEqual(request_method.call_args[0],
                         ('post', _('gists/1/fork')))

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response('delete')
        self.gs.delete(1)
        self.assertEqual(request_method.call_args[0], ('delete', _('gists/1')))
예제 #5
0
 def setUp(self):
     self.gs = Gist()
예제 #6
0
class TestGistService(TestCase):

    def setUp(self):
        self.gs = Gist()

    def test_LIST_without_user(self, request_method):
        request_method.return_value = mock_response_result()
        self.gs.list().all()
        self.assertEqual(request_method.call_args[0], ('get', _('gists')))

    def test_LIST_with_user(self, request_method):
        request_method.return_value = mock_response_result()
        self.gs.list('octocat').all()
        self.assertEqual(request_method.call_args[0],
            ('get', _('users/octocat/gists')))

    def test_LIST_public(self, request_method):
        request_method.return_value = mock_response_result()
        self.gs.public().all()
        self.assertEqual(request_method.call_args[0],
            ('get', _('gists/public')))

    def test_LIST_starred(self, request_method):
        request_method.return_value = mock_response_result()
        self.gs.starred().all()
        self.assertEqual(request_method.call_args[0],
            ('get', _('gists/starred')))

    def test_GET(self, request_method):
        request_method.return_value = mock_response()
        self.gs.get(1)
        self.assertEqual(request_method.call_args[0],
            ('get', _('gists/1')))

    def test_CREATE(self, request_method):
        request_method.return_value = mock_response('post')
        self.gs.create(dict(public=True, files={
            'file1.txt': {'content': 'Some\ncontent'}}))
        self.assertEqual(request_method.call_args[0],
            ('post', _('gists')))

    def test_UPDATE(self, request_method):
        request_method.return_value = mock_response('patch')
        self.gs.update(1, {'description': 'edited'})
        self.assertEqual(request_method.call_args[0],
            ('patch', _('gists/1')))

    def test_STAR(self, request_method):
        self.gs.star(1)
        self.assertEqual(request_method.call_args[0],
            ('put', _('gists/1/star')))

    def test_UNSTAR(self, request_method):
        request_method.return_value = mock_response('delete')
        self.gs.unstar(1)
        self.assertEqual(request_method.call_args[0],
            ('delete', _('gists/1/star')))

    def test_IS_STARRED(self, request_method):
        request_method.return_value = mock_response()
        self.gs.is_starred(1)
        self.assertEqual(request_method.call_args[0],
            ('head', _('gists/1/star')))

    def test_FORK(self, request_method):
        request_method.return_value = mock_response('post')
        self.gs.fork(1)
        self.assertEqual(request_method.call_args[0],
            ('post', _('gists/1/fork')))

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response('delete')
        self.gs.delete(1)
        self.assertEqual(request_method.call_args[0],
            ('delete', _('gists/1')))