Example #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)
 def handle(self, *args, **options):
     if len(args) > 0:
         if args[0] == "create":
             for pending_repo in GitRepo.objects.filter(is_active=False):
                 repo_name = slugify(pending_repo.project_set.all()[0])
                 repo_service = Repo(login=GIT_LOGIN, password=GIT_PASSWORD)
                 repo_service.create(
                     dict(name=repo_name, description='desc'))
                 repo = repo_service.get(user="******", repo=repo_name)
                 pending_repo.url = repo.clone_url
                 pending_repo.is_active = True
                 pending_repo.save()
         else:
             print("There were no valid arguments")
     else:
         print("There were no valid arguments")
 def handle(self, *args, **options):
     if len(args) > 0:
         if args[0] == "create":
             for pending_repo in GitRepo.objects.filter(is_active=False):
                 repo_name = slugify(pending_repo.project_set.all()[0])
                 repo_service = Repo(login=GIT_LOGIN, password=GIT_PASSWORD)
                 repo_service.create(dict(name=repo_name, description='desc'))
                 repo = repo_service.get(user="******",repo=repo_name)
                 pending_repo.url = repo.clone_url
                 pending_repo.is_active = True
                 pending_repo.save()
         else:
             print("There were no valid arguments")
     else:
         print("There were no valid arguments")
         ##add error handling  
Example #4
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)
Example #5
0
from pygithub3.services.repos import Repo
'''
cmd = "git shortlog -s -n"

os.chdir("C:\Users\DhruvOhri\Documents\COMP 6411\pygithub3-0.3")
os.system("git clone https://github.com/poise/python.git")
os.chdir("/home/d/d_ohri/Desktop/python")
output = commands.getoutput(cmd) 
print(output)
raw_input("press enter to continue")

'''

#r = github3.repository('poise', 'python')
r = Repo()
r1 = r.list_contributors('poise', 'python')
for page in r1:
    for resource in page:
        print resource
Example #6
0
 def setUp(self):
     self.rs = Repo()
     self.rs.set_user('octocat')
     self.rs.set_repo('octocat_repo')
Example #7
0
class TestRepoService(TestCase):

    def setUp(self):
        self.rs = Repo()
        self.rs.set_user('octocat')
        self.rs.set_repo('octocat_repo')

    def test_LIST_without_user(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.set_user('')
        self.rs.list().all()
        self.assertEqual(request_method.call_args[0], ('get', _('user/repos')))

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

    def test_LIST_filters(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list('octoc', type='public').all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('users/octoc/repos')))
        self.assertEqual(request_method.call_args[1]['params']['type'],
                         'public')

    def test_LIST_BY_ORG(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_by_org('org_name').all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('orgs/org_name/repos')))

    def test_LIST_BY_ORG_filters(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_by_org('org_name', type='public').all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('orgs/org_name/repos')))
        self.assertEqual(request_method.call_args[1]['params']['type'],
                         'public')

    def test_CREATE(self, request_method):
        request_method.return_value = mock_response('post')
        self.rs.create({'name': 'test'})
        self.assertEqual(request_method.call_args[0],
                         ('post', _('user/repos')))

    def test_CREATE_in_org(self, request_method):
        request_method.return_value = mock_response('post')
        self.rs.create({'name': 'test'}, in_org='org_name')
        self.assertEqual(request_method.call_args[0],
                         ('post', _('orgs/org_name/repos')))

    def test_GET_with_repo_in_args(self, request_method):
        request_method.return_value = mock_response()
        self.rs.get(user='******', repo='repo')
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/user/repo')))

    def test_GET_with_repo_in_service(self, request_method):
        request_method.return_value = mock_response()
        self.rs.get()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo')))

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response('delete')
        self.rs.delete()
        self.assertEqual(request_method.call_args[0],
                         ('delete', _('repos/octocat/octocat_repo')))

    def test_UPDATE_with_repo_in_args(self, request_method):
        request_method.return_value = mock_response('patch')
        self.rs.update({'name': 'test'}, user='******', repo='repo')
        self.assertEqual(request_method.call_args[0],
                         ('patch', _('repos/user/repo')))

    def test_UPDATE_with_repo_in_service(self, request_method):
        request_method.return_value = mock_response('patch')
        self.rs.update({'name': 'test'})
        self.assertEqual(request_method.call_args[0],
                         ('patch', _('repos/octocat/octocat_repo')))

    """ From here I stop to do '*in_args' and '*filter' tests, I consider
    that I tested it enough... """

    def test_LIST_contributors(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_contributors().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/contributors')))

    def test_LIST_contributors_with_anonymous(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_contributors_with_anonymous().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/contributors')))
        self.assertEqual(request_method.call_args[1]['params']['anom'], True)

    def test_LIST_languages(self, request_method):
        request_method.return_value = mock_response()
        self.rs.list_languages()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/languages')))

    def test_LIST_teams(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_teams().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/teams')))

    def test_LIST_tags(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_tags().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/tags')))

    def test_LIST_branches(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_branches().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/branches')))
Example #8
0
 def setUp(self):
     self.rs = Repo()
     self.rs.set_user('octocat')
     self.rs.set_repo('octocat_repo')
Example #9
0
class TestRepoService(TestCase):
    def setUp(self):
        self.rs = Repo()
        self.rs.set_user('octocat')
        self.rs.set_repo('octocat_repo')

    def test_LIST_without_user(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.set_user('')
        self.rs.list().all()
        self.assertEqual(request_method.call_args[0], ('get', _('user/repos')))

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

    def test_LIST_filters(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list('octoc', type='public').all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('users/octoc/repos')))
        self.assertEqual(request_method.call_args[1]['params']['type'],
                         'public')

    def test_LIST_BY_ORG(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_by_org('org_name').all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('orgs/org_name/repos')))

    def test_LIST_BY_ORG_filters(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_by_org('org_name', type='public').all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('orgs/org_name/repos')))
        self.assertEqual(request_method.call_args[1]['params']['type'],
                         'public')

    def test_CREATE(self, request_method):
        request_method.return_value = mock_response('post')
        self.rs.create({'name': 'test'})
        self.assertEqual(request_method.call_args[0],
                         ('post', _('user/repos')))

    def test_CREATE_in_org(self, request_method):
        request_method.return_value = mock_response('post')
        self.rs.create({'name': 'test'}, in_org='org_name')
        self.assertEqual(request_method.call_args[0],
                         ('post', _('orgs/org_name/repos')))

    def test_GET_with_repo_in_args(self, request_method):
        request_method.return_value = mock_response()
        self.rs.get(user='******', repo='repo')
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/user/repo')))

    def test_GET_with_repo_in_service(self, request_method):
        request_method.return_value = mock_response()
        self.rs.get()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo')))

    def test_UPDATE_with_repo_in_args(self, request_method):
        request_method.return_value = mock_response('patch')
        self.rs.update({'name': 'test'}, user='******', repo='repo')
        self.assertEqual(request_method.call_args[0],
                         ('patch', _('repos/user/repo')))

    def test_UPDATE_with_repo_in_service(self, request_method):
        request_method.return_value = mock_response('patch')
        self.rs.update({'name': 'test'})
        self.assertEqual(request_method.call_args[0],
                         ('patch', _('repos/octocat/octocat_repo')))

    """ From here I stop to do '*in_args' and '*filter' tests, I consider
    that I tested it enough... """

    def test_LIST_contributors(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_contributors().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/contributors')))

    def test_LIST_contributors_with_anonymous(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_contributors_with_anonymous().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/contributors')))
        self.assertEqual(request_method.call_args[1]['params']['anom'], True)

    def test_LIST_languages(self, request_method):
        request_method.return_value = mock_response()
        self.rs.list_languages()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/languages')))

    def test_LIST_teams(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_teams().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/teams')))

    def test_LIST_tags(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_tags().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/tags')))

    def test_LIST_branches(self, request_method):
        request_method.return_value = mock_response_result()
        self.rs.list_branches().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/octocat/octocat_repo/branches')))