diff --git a/github/Repository.py b/github/Repository.py index 839ae1f3..ccdf8811 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -107,6 +107,7 @@ import github.Download import github.Permissions import github.Event import github.Legacy +import github.SourceImport import github.StatsContributor import github.StatsCommitActivity import github.StatsCodeFrequency @@ -1092,6 +1093,41 @@ class Repository(github.GithubObject.CompletableGithubObject): ) return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) + def create_source_import(self, vcs, vcs_url, vcs_username=github.GithubObject.NotSet, vcs_password=github.GithubObject.NotSet): + """ + :calls: `PUT /repos/:owner/:repo/import https://developer.github.com/v3/migration/source_imports/#start-an-import`_ + :param vcs: string + :param vcs_url: string + :param vcs_username: string + :param vcs_password: string + :rtype: :class:`github.SourceImport.SourceImport` + """ + assert isinstance(vcs, (str, unicode)), vcs + assert isinstance(vcs_url, (str, unicode)), vcs_url + assert vcs_username is github.GithubObject.NotSet or isinstance(vcs_username, (str, unicode)), vcs_username + assert vcs_password is github.GithubObject.NotSet or isinstance(vcs_password, (str, unicode)), vcs_password + put_parameters = { + "vcs": vcs, + "vcs_url": vcs_url + } + + if vcs_username is not github.GithubObject.NotSet: + put_parameters["vcs_username"] = vcs_username + + if vcs_password is not github.GithubObject.NotSet: + put_parameters["vcs_password"] = vcs_password + + import_header = {"Accept": "application/vnd.github.barred-rock-preview"} + + headers, data = self._requester.requestJsonAndCheck( + "PUT", + self.url + "/import", + headers=import_header, + input=put_parameters + ) + + return github.SourceImport.SourceImport(self._requester, headers, data, completed=False) + def delete(self): """ :calls: `DELETE /repos/:owner/:repo `_ @@ -2040,6 +2076,22 @@ class Repository(github.GithubObject.CompletableGithubObject): ) return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) + def get_source_import(self): + """ + :calls: `GET /repos/:owner/:repo/import https://developer.github.com/v3/migration/source_imports/#get-import-progress`_ + :rtype: :class:`github.SourceImport.SourceImport` + """ + import_header = {"Accept": "application/vnd.github.barred-rock-preview"} + headers, data = self._requester.requestJsonAndCheck( + "GET", + self.url + "/import", + headers=import_header, + ) + if not data: + return None + else: + return github.SourceImport.SourceImport(self._requester, headers, data, completed=True) + def get_stargazers(self): """ :calls: `GET /repos/:owner/:repo/stargazers `_ diff --git a/github/SourceImport.py b/github/SourceImport.py new file mode 100644 index 00000000..647a2e5a --- /dev/null +++ b/github/SourceImport.py @@ -0,0 +1,188 @@ +# -*- coding: utf-8 -*- + +# ########################## Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +# ############################################################################## + +import github.GithubObject + + +class SourceImport(github.GithubObject.CompletableGithubObject): + """ + This class represents SourceImports. The reference can be found here https://developer.github.com/v3/migration/source_imports/ + """ + + def __repr__(self): + return self.get__repr__({ + "vcs_url": self._vcs_url.value, + "repository_url": self._repository_url.value, + "status": self._status.value, + "url": self._url.value + }) + + @property + def authors_count(self): + """ + :type: integer + """ + self._completeIfNotSet(self._authors_count) + return self._authors_count.value + + @property + def authors_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._authors_url) + return self._authors_url.value + + @property + def has_large_files(self): + """ + :type: bool + """ + self._completeIfNotSet(self._has_large_files) + return self._has_large_files.value + + @property + def html_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def large_files_count(self): + """ + :type: integer + """ + self._completeIfNotSet(self._large_files_count) + return self._large_files_count.value + + @property + def large_files_size(self): + """ + :type: integer + """ + self._completeIfNotSet(self._large_files_size) + return self._large_files_size.value + + @property + def repository_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._repository_url) + return self._repository_url.value + + @property + def status(self): + """ + :type: string + """ + self._completeIfNotSet(self._status) + return self._status.value + + @property + def status_text(self): + """ + :type: string + """ + self._completeIfNotSet(self._status_text) + return self._status_text.value + + @property + def url(self): + """ + :type: string + """ + self._completeIfNotSet(self._url) + return self._url.value + + @property + def use_lfs(self): + """ + :type: string + """ + self._completeIfNotSet(self._use_lfs) + return self._use_lfs.value + + @property + def vcs(self): + """ + :type: string + """ + self._completeIfNotSet(self._vcs) + return self._vcs.value + + @property + def vcs_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._vcs_url) + return self._vcs_url.value + + def _initAttributes(self): + self._authors_count = github.GithubObject.NotSet + self._authors_url = github.GithubObject.NotSet + self._has_large_files = github.GithubObject.NotSet + self._html_url = github.GithubObject.NotSet + self._large_files_count = github.GithubObject.NotSet + self._large_files_size = github.GithubObject.NotSet + self._repository_url = github.GithubObject.NotSet + self._status = github.GithubObject.NotSet + self._status_text = github.GithubObject.NotSet + self._url = github.GithubObject.NotSet + self._use_lsf = github.GithubObject.NotSet + self._vcs = github.GithubObject.NotSet + self._vcs_url = github.GithubObject.NotSet + + def _useAttributes(self, attributes): + if "authors_count" in attributes: # pragma no branch + self._authors_count = self._makeIntAttribute(attributes["authors_count"]) + if "authors_url" in attributes: # pragma no branch + self._authors_url = self._makeStringAttribute(attributes["authors_url"]) + if "has_large_files" in attributes: # pragma no branch + self._has_large_files = self._makeBoolAttribute(attributes["has_large_files"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "large_files_count" in attributes: # pragma no branch + self._large_files_count = self._makeIntAttribute(attributes["large_files_count"]) + if "large_files_size" in attributes: # pragma no branch + self._large_files_size = self._makeIntAttribute(attributes["large_files_size"]) + if "repository_url" in attributes: # pragma no branch + self._repository_url = self._makeStringAttribute(attributes["repository_url"]) + if "status" in attributes: # pragma no branch + self._status = self._makeStringAttribute(attributes["status"]) + if "status_text" in attributes: # pragma no branch + self._status_text = self._makeStringAttribute(attributes["status_text"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "use_lfs" in attributes: # pragma no branch + self._use_lfs = self._makeStringAttribute(attributes["use_lfs"]) + if "vcs" in attributes: # pragma no branch + self._vcs = self._makeStringAttribute(attributes["vcs"]) + if "vcs_url" in attributes: # pragma no branch + self._vcs_url = self._makeStringAttribute(attributes["vcs_url"]) diff --git a/github/tests/AllTests.py b/github/tests/AllTests.py index 4db8bb03..279dddbb 100644 --- a/github/tests/AllTests.py +++ b/github/tests/AllTests.py @@ -74,6 +74,7 @@ from PullRequestFile import * from RateLimiting import * from Repository import * from RepositoryKey import * +from SourceImport import * from Status import * from Tag import * from Team import * diff --git a/github/tests/ReplayData/Repository.testCreateSourceImport.txt b/github/tests/ReplayData/Repository.testCreateSourceImport.txt new file mode 100644 index 00000000..e7b32b83 --- /dev/null +++ b/github/tests/ReplayData/Repository.testCreateSourceImport.txt @@ -0,0 +1,33 @@ +https +GET +api.github.com +None +/users/brix4dayz +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '1143'), ('x-runtime-rack', '0.035038'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('x-oauth-scopes', 'repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"5f005737679e3703efce7e706ad4fe72"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4991'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D3C7:2058:1F1200E:4D1FC03:5A374B66'), ('last-modified', 'Mon, 18 Dec 2017 01:31:56 GMT'), ('date', 'Mon, 18 Dec 2017 05:00:22 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1513576416')] +{"login":"brix4dayz","id":11233384,"avatar_url":"https://avatars0.githubusercontent.com/u/11233384?v=4","gravatar_id":"","url":"https://api.github.com/users/brix4dayz","html_url":"https://github.com/brix4dayz","followers_url":"https://api.github.com/users/brix4dayz/followers","following_url":"https://api.github.com/users/brix4dayz/following{/other_user}","gists_url":"https://api.github.com/users/brix4dayz/gists{/gist_id}","starred_url":"https://api.github.com/users/brix4dayz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brix4dayz/subscriptions","organizations_url":"https://api.github.com/users/brix4dayz/orgs","repos_url":"https://api.github.com/users/brix4dayz/repos","events_url":"https://api.github.com/users/brix4dayz/events{/privacy}","received_events_url":"https://api.github.com/users/brix4dayz/received_events","type":"User","site_admin":false,"name":"Hayden Fuss","company":"Bandwidth.com","blog":"","location":"Raleigh, NC","email":null,"hireable":null,"bio":null,"public_repos":9,"public_gists":0,"followers":4,"following":5,"created_at":"2015-02-27T17:32:06Z","updated_at":"2017-12-18T01:31:56Z"} + +https +GET +api.github.com +None +/repos/brix4dayz/source-import-test +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '5271'), ('x-runtime-rack', '0.043773'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('x-oauth-scopes', 'repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', 'repo'), ('etag', '"5e0980fc96c1a102fba789b8d834a7fa"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4990'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D3C8:2058:1F12026:4D1FC44:5A374B67'), ('last-modified', 'Mon, 18 Dec 2017 05:00:03 GMT'), ('date', 'Mon, 18 Dec 2017 05:00:23 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1513576416')] +{"id":114597626,"name":"source-import-test","full_name":"brix4dayz/source-import-test","owner":{"login":"brix4dayz","id":11233384,"avatar_url":"https://avatars0.githubusercontent.com/u/11233384?v=4","gravatar_id":"","url":"https://api.github.com/users/brix4dayz","html_url":"https://github.com/brix4dayz","followers_url":"https://api.github.com/users/brix4dayz/followers","following_url":"https://api.github.com/users/brix4dayz/following{/other_user}","gists_url":"https://api.github.com/users/brix4dayz/gists{/gist_id}","starred_url":"https://api.github.com/users/brix4dayz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brix4dayz/subscriptions","organizations_url":"https://api.github.com/users/brix4dayz/orgs","repos_url":"https://api.github.com/users/brix4dayz/repos","events_url":"https://api.github.com/users/brix4dayz/events{/privacy}","received_events_url":"https://api.github.com/users/brix4dayz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brix4dayz/source-import-test","description":null,"fork":false,"url":"https://api.github.com/repos/brix4dayz/source-import-test","forks_url":"https://api.github.com/repos/brix4dayz/source-import-test/forks","keys_url":"https://api.github.com/repos/brix4dayz/source-import-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brix4dayz/source-import-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brix4dayz/source-import-test/teams","hooks_url":"https://api.github.com/repos/brix4dayz/source-import-test/hooks","issue_events_url":"https://api.github.com/repos/brix4dayz/source-import-test/issues/events{/number}","events_url":"https://api.github.com/repos/brix4dayz/source-import-test/events","assignees_url":"https://api.github.com/repos/brix4dayz/source-import-test/assignees{/user}","branches_url":"https://api.github.com/repos/brix4dayz/source-import-test/branches{/branch}","tags_url":"https://api.github.com/repos/brix4dayz/source-import-test/tags","blobs_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brix4dayz/source-import-test/statuses/{sha}","languages_url":"https://api.github.com/repos/brix4dayz/source-import-test/languages","stargazers_url":"https://api.github.com/repos/brix4dayz/source-import-test/stargazers","contributors_url":"https://api.github.com/repos/brix4dayz/source-import-test/contributors","subscribers_url":"https://api.github.com/repos/brix4dayz/source-import-test/subscribers","subscription_url":"https://api.github.com/repos/brix4dayz/source-import-test/subscription","commits_url":"https://api.github.com/repos/brix4dayz/source-import-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/brix4dayz/source-import-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/brix4dayz/source-import-test/issues/comments{/number}","contents_url":"https://api.github.com/repos/brix4dayz/source-import-test/contents/{+path}","compare_url":"https://api.github.com/repos/brix4dayz/source-import-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brix4dayz/source-import-test/merges","archive_url":"https://api.github.com/repos/brix4dayz/source-import-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brix4dayz/source-import-test/downloads","issues_url":"https://api.github.com/repos/brix4dayz/source-import-test/issues{/number}","pulls_url":"https://api.github.com/repos/brix4dayz/source-import-test/pulls{/number}","milestones_url":"https://api.github.com/repos/brix4dayz/source-import-test/milestones{/number}","notifications_url":"https://api.github.com/repos/brix4dayz/source-import-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brix4dayz/source-import-test/labels{/name}","releases_url":"https://api.github.com/repos/brix4dayz/source-import-test/releases{/id}","deployments_url":"https://api.github.com/repos/brix4dayz/source-import-test/deployments","created_at":"2017-12-18T05:00:03Z","updated_at":"2017-12-18T05:00:03Z","pushed_at":"2017-12-18T05:00:03Z","git_url":"git://github.com/brix4dayz/source-import-test.git","ssh_url":"git@github.com:brix4dayz/source-import-test.git","clone_url":"https://github.com/brix4dayz/source-import-test.git","svn_url":"https://github.com/brix4dayz/source-import-test","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"network_count":0,"subscribers_count":1} + +https +PUT +api.github.com +None +/repos/brix4dayz/source-import-test/import +{'Content-Type': 'application/json', 'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.barred-rock-preview', 'User-Agent': 'PyGithub/Python'} +{"vcs": "mercurial", "vcs_url": "https://bitbucket.org/hfuss/source-import-test"} +201 +[('content-length', '517'), ('x-runtime-rack', '0.115876'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('x-oauth-scopes', 'repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"57e00a16a64505bd7f87786614faefcc"'), ('location', 'https://api.github.com/repos/brix4dayz/source-import-test/import'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '201 Created'), ('x-ratelimit-remaining', '99'), ('x-github-media-type', 'github.barred-rock-preview'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D3C9:204B:1540BC5:2C515EA:5A374B67'), ('date', 'Mon, 18 Dec 2017 05:00:23 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '100'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1513573283')] +{"vcs":"mercurial","use_lfs":"undecided","vcs_url":"https://bitbucket.org/hfuss/source-import-test","status":"importing","commit_count":null,"status_text":"Importing...","authors_count":0,"import_percent":null,"url":"https://api.github.com/repos/brix4dayz/source-import-test/import","html_url":"https://github.com/brix4dayz/source-import-test/import","authors_url":"https://api.github.com/repos/brix4dayz/source-import-test/import/authors","repository_url":"https://api.github.com/repos/brix4dayz/source-import-test"} + diff --git a/github/tests/ReplayData/Repository.testGetSourceImport.txt b/github/tests/ReplayData/Repository.testGetSourceImport.txt new file mode 100644 index 00000000..b50fd29e --- /dev/null +++ b/github/tests/ReplayData/Repository.testGetSourceImport.txt @@ -0,0 +1,33 @@ +https +GET +api.github.com +None +/users/brix4dayz +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '1143'), ('x-runtime-rack', '0.036199'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('x-oauth-scopes', 'repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"5f005737679e3703efce7e706ad4fe72"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4997'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D38A:204B:1537888:2C3DF24:5A3749D0'), ('last-modified', 'Mon, 18 Dec 2017 01:31:56 GMT'), ('date', 'Mon, 18 Dec 2017 04:53:36 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1513576416')] +{"login":"brix4dayz","id":11233384,"avatar_url":"https://avatars0.githubusercontent.com/u/11233384?v=4","gravatar_id":"","url":"https://api.github.com/users/brix4dayz","html_url":"https://github.com/brix4dayz","followers_url":"https://api.github.com/users/brix4dayz/followers","following_url":"https://api.github.com/users/brix4dayz/following{/other_user}","gists_url":"https://api.github.com/users/brix4dayz/gists{/gist_id}","starred_url":"https://api.github.com/users/brix4dayz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brix4dayz/subscriptions","organizations_url":"https://api.github.com/users/brix4dayz/orgs","repos_url":"https://api.github.com/users/brix4dayz/repos","events_url":"https://api.github.com/users/brix4dayz/events{/privacy}","received_events_url":"https://api.github.com/users/brix4dayz/received_events","type":"User","site_admin":false,"name":"Hayden Fuss","company":"Bandwidth.com","blog":"","location":"Raleigh, NC","email":null,"hireable":null,"bio":null,"public_repos":9,"public_gists":0,"followers":4,"following":5,"created_at":"2015-02-27T17:32:06Z","updated_at":"2017-12-18T01:31:56Z"} + +https +GET +api.github.com +None +/repos/brix4dayz/source-import-test +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '5271'), ('x-runtime-rack', '0.045121'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('x-oauth-scopes', 'repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', 'repo'), ('etag', '"bfe90beb5d300f2556ac2156c7a06731"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4996'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D38B:204B:1537892:2C3DF3E:5A3749D0'), ('last-modified', 'Mon, 18 Dec 2017 03:41:58 GMT'), ('date', 'Mon, 18 Dec 2017 04:53:36 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1513576416')] +{"id":114593046,"name":"source-import-test","full_name":"brix4dayz/source-import-test","owner":{"login":"brix4dayz","id":11233384,"avatar_url":"https://avatars0.githubusercontent.com/u/11233384?v=4","gravatar_id":"","url":"https://api.github.com/users/brix4dayz","html_url":"https://github.com/brix4dayz","followers_url":"https://api.github.com/users/brix4dayz/followers","following_url":"https://api.github.com/users/brix4dayz/following{/other_user}","gists_url":"https://api.github.com/users/brix4dayz/gists{/gist_id}","starred_url":"https://api.github.com/users/brix4dayz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brix4dayz/subscriptions","organizations_url":"https://api.github.com/users/brix4dayz/orgs","repos_url":"https://api.github.com/users/brix4dayz/repos","events_url":"https://api.github.com/users/brix4dayz/events{/privacy}","received_events_url":"https://api.github.com/users/brix4dayz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brix4dayz/source-import-test","description":null,"fork":false,"url":"https://api.github.com/repos/brix4dayz/source-import-test","forks_url":"https://api.github.com/repos/brix4dayz/source-import-test/forks","keys_url":"https://api.github.com/repos/brix4dayz/source-import-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brix4dayz/source-import-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brix4dayz/source-import-test/teams","hooks_url":"https://api.github.com/repos/brix4dayz/source-import-test/hooks","issue_events_url":"https://api.github.com/repos/brix4dayz/source-import-test/issues/events{/number}","events_url":"https://api.github.com/repos/brix4dayz/source-import-test/events","assignees_url":"https://api.github.com/repos/brix4dayz/source-import-test/assignees{/user}","branches_url":"https://api.github.com/repos/brix4dayz/source-import-test/branches{/branch}","tags_url":"https://api.github.com/repos/brix4dayz/source-import-test/tags","blobs_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brix4dayz/source-import-test/statuses/{sha}","languages_url":"https://api.github.com/repos/brix4dayz/source-import-test/languages","stargazers_url":"https://api.github.com/repos/brix4dayz/source-import-test/stargazers","contributors_url":"https://api.github.com/repos/brix4dayz/source-import-test/contributors","subscribers_url":"https://api.github.com/repos/brix4dayz/source-import-test/subscribers","subscription_url":"https://api.github.com/repos/brix4dayz/source-import-test/subscription","commits_url":"https://api.github.com/repos/brix4dayz/source-import-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/brix4dayz/source-import-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/brix4dayz/source-import-test/issues/comments{/number}","contents_url":"https://api.github.com/repos/brix4dayz/source-import-test/contents/{+path}","compare_url":"https://api.github.com/repos/brix4dayz/source-import-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brix4dayz/source-import-test/merges","archive_url":"https://api.github.com/repos/brix4dayz/source-import-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brix4dayz/source-import-test/downloads","issues_url":"https://api.github.com/repos/brix4dayz/source-import-test/issues{/number}","pulls_url":"https://api.github.com/repos/brix4dayz/source-import-test/pulls{/number}","milestones_url":"https://api.github.com/repos/brix4dayz/source-import-test/milestones{/number}","notifications_url":"https://api.github.com/repos/brix4dayz/source-import-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brix4dayz/source-import-test/labels{/name}","releases_url":"https://api.github.com/repos/brix4dayz/source-import-test/releases{/id}","deployments_url":"https://api.github.com/repos/brix4dayz/source-import-test/deployments","created_at":"2017-12-18T03:41:58Z","updated_at":"2017-12-18T03:41:58Z","pushed_at":"2017-12-18T03:46:11Z","git_url":"git://github.com/brix4dayz/source-import-test.git","ssh_url":"git@github.com:brix4dayz/source-import-test.git","clone_url":"https://github.com/brix4dayz/source-import-test.git","svn_url":"https://github.com/brix4dayz/source-import-test","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"network_count":0,"subscribers_count":1} + +https +GET +api.github.com +None +/repos/brix4dayz/source-import-test/import +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.barred-rock-preview', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '533'), ('x-runtime-rack', '0.160871'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('x-oauth-scopes', 'repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"8659af05bfc77665551bec8f8a6bb2ce"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4994'), ('x-github-media-type', 'github.barred-rock-preview'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D38C:203D:AEDFE1:183A6DE:5A3749D0'), ('date', 'Mon, 18 Dec 2017 04:53:37 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1513576416')] +{"vcs":"mercurial","use_lfs":"undecided","vcs_url":"https://bitbucket.org/hfuss/source-import-test","status":"complete","status_text":"Done","has_large_files":false,"large_files_size":0,"large_files_count":0,"authors_count":1,"url":"https://api.github.com/repos/brix4dayz/source-import-test/import","html_url":"https://github.com/brix4dayz/source-import-test/import","authors_url":"https://api.github.com/repos/brix4dayz/source-import-test/import/authors","repository_url":"https://api.github.com/repos/brix4dayz/source-import-test"} + diff --git a/github/tests/ReplayData/SourceImport.setUp.txt b/github/tests/ReplayData/SourceImport.setUp.txt new file mode 100644 index 00000000..fcf4c10d --- /dev/null +++ b/github/tests/ReplayData/SourceImport.setUp.txt @@ -0,0 +1,33 @@ +https +GET +api.github.com +None +/users/brix4dayz +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '1143'), ('x-runtime-rack', '0.037535'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('x-oauth-scopes', 'repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"5f005737679e3703efce7e706ad4fe72"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4990'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D34B:203D:AE7A72:182C586:5A374787'), ('last-modified', 'Mon, 18 Dec 2017 01:31:56 GMT'), ('date', 'Mon, 18 Dec 2017 04:43:51 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1513572653')] +{"login":"brix4dayz","id":11233384,"avatar_url":"https://avatars0.githubusercontent.com/u/11233384?v=4","gravatar_id":"","url":"https://api.github.com/users/brix4dayz","html_url":"https://github.com/brix4dayz","followers_url":"https://api.github.com/users/brix4dayz/followers","following_url":"https://api.github.com/users/brix4dayz/following{/other_user}","gists_url":"https://api.github.com/users/brix4dayz/gists{/gist_id}","starred_url":"https://api.github.com/users/brix4dayz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brix4dayz/subscriptions","organizations_url":"https://api.github.com/users/brix4dayz/orgs","repos_url":"https://api.github.com/users/brix4dayz/repos","events_url":"https://api.github.com/users/brix4dayz/events{/privacy}","received_events_url":"https://api.github.com/users/brix4dayz/received_events","type":"User","site_admin":false,"name":"Hayden Fuss","company":"Bandwidth.com","blog":"","location":"Raleigh, NC","email":null,"hireable":null,"bio":null,"public_repos":9,"public_gists":0,"followers":4,"following":5,"created_at":"2015-02-27T17:32:06Z","updated_at":"2017-12-18T01:31:56Z"} + +https +GET +api.github.com +None +/repos/brix4dayz/source-import-test +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '5271'), ('x-runtime-rack', '0.059841'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('x-oauth-scopes', 'repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', 'repo'), ('etag', '"bfe90beb5d300f2556ac2156c7a06731"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4989'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D34C:204B:1529C80:2C2201E:5A374787'), ('last-modified', 'Mon, 18 Dec 2017 03:41:58 GMT'), ('date', 'Mon, 18 Dec 2017 04:43:51 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1513572653')] +{"id":114593046,"name":"source-import-test","full_name":"brix4dayz/source-import-test","owner":{"login":"brix4dayz","id":11233384,"avatar_url":"https://avatars0.githubusercontent.com/u/11233384?v=4","gravatar_id":"","url":"https://api.github.com/users/brix4dayz","html_url":"https://github.com/brix4dayz","followers_url":"https://api.github.com/users/brix4dayz/followers","following_url":"https://api.github.com/users/brix4dayz/following{/other_user}","gists_url":"https://api.github.com/users/brix4dayz/gists{/gist_id}","starred_url":"https://api.github.com/users/brix4dayz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brix4dayz/subscriptions","organizations_url":"https://api.github.com/users/brix4dayz/orgs","repos_url":"https://api.github.com/users/brix4dayz/repos","events_url":"https://api.github.com/users/brix4dayz/events{/privacy}","received_events_url":"https://api.github.com/users/brix4dayz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brix4dayz/source-import-test","description":null,"fork":false,"url":"https://api.github.com/repos/brix4dayz/source-import-test","forks_url":"https://api.github.com/repos/brix4dayz/source-import-test/forks","keys_url":"https://api.github.com/repos/brix4dayz/source-import-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brix4dayz/source-import-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brix4dayz/source-import-test/teams","hooks_url":"https://api.github.com/repos/brix4dayz/source-import-test/hooks","issue_events_url":"https://api.github.com/repos/brix4dayz/source-import-test/issues/events{/number}","events_url":"https://api.github.com/repos/brix4dayz/source-import-test/events","assignees_url":"https://api.github.com/repos/brix4dayz/source-import-test/assignees{/user}","branches_url":"https://api.github.com/repos/brix4dayz/source-import-test/branches{/branch}","tags_url":"https://api.github.com/repos/brix4dayz/source-import-test/tags","blobs_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brix4dayz/source-import-test/statuses/{sha}","languages_url":"https://api.github.com/repos/brix4dayz/source-import-test/languages","stargazers_url":"https://api.github.com/repos/brix4dayz/source-import-test/stargazers","contributors_url":"https://api.github.com/repos/brix4dayz/source-import-test/contributors","subscribers_url":"https://api.github.com/repos/brix4dayz/source-import-test/subscribers","subscription_url":"https://api.github.com/repos/brix4dayz/source-import-test/subscription","commits_url":"https://api.github.com/repos/brix4dayz/source-import-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/brix4dayz/source-import-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/brix4dayz/source-import-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/brix4dayz/source-import-test/issues/comments{/number}","contents_url":"https://api.github.com/repos/brix4dayz/source-import-test/contents/{+path}","compare_url":"https://api.github.com/repos/brix4dayz/source-import-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brix4dayz/source-import-test/merges","archive_url":"https://api.github.com/repos/brix4dayz/source-import-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brix4dayz/source-import-test/downloads","issues_url":"https://api.github.com/repos/brix4dayz/source-import-test/issues{/number}","pulls_url":"https://api.github.com/repos/brix4dayz/source-import-test/pulls{/number}","milestones_url":"https://api.github.com/repos/brix4dayz/source-import-test/milestones{/number}","notifications_url":"https://api.github.com/repos/brix4dayz/source-import-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brix4dayz/source-import-test/labels{/name}","releases_url":"https://api.github.com/repos/brix4dayz/source-import-test/releases{/id}","deployments_url":"https://api.github.com/repos/brix4dayz/source-import-test/deployments","created_at":"2017-12-18T03:41:58Z","updated_at":"2017-12-18T03:41:58Z","pushed_at":"2017-12-18T03:46:11Z","git_url":"git://github.com/brix4dayz/source-import-test.git","ssh_url":"git@github.com:brix4dayz/source-import-test.git","clone_url":"https://github.com/brix4dayz/source-import-test.git","svn_url":"https://github.com/brix4dayz/source-import-test","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"network_count":0,"subscribers_count":1} + +https +GET +api.github.com +None +/repos/brix4dayz/source-import-test/import +{'Authorization': 'Basic login_and_password_removed', 'Accept': 'application/vnd.github.barred-rock-preview', 'User-Agent': 'PyGithub/Python'} +null +200 +[('content-length', '533'), ('x-runtime-rack', '0.137115'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('x-oauth-scopes', 'repo'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"8659af05bfc77665551bec8f8a6bb2ce"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('x-github-media-type', 'github.barred-rock-preview'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'D34D:2057:22D5E83:4403573:5A374787'), ('date', 'Mon, 18 Dec 2017 04:43:51 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1513572653')] +{"vcs":"mercurial","use_lfs":"undecided","vcs_url":"https://bitbucket.org/hfuss/source-import-test","status":"complete","status_text":"Done","has_large_files":false,"large_files_size":0,"large_files_count":0,"authors_count":1,"url":"https://api.github.com/repos/brix4dayz/source-import-test/import","html_url":"https://github.com/brix4dayz/source-import-test/import","authors_url":"https://api.github.com/repos/brix4dayz/source-import-test/import/authors","repository_url":"https://api.github.com/repos/brix4dayz/source-import-test"} + diff --git a/github/tests/Repository.py b/github/tests/Repository.py index 89e080ce..b19b592d 100644 --- a/github/tests/Repository.py +++ b/github/tests/Repository.py @@ -349,6 +349,19 @@ class Repository(Framework.TestCase): key = self.repo.create_key("Key added through PyGithub", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw== vincent@IDEE") self.assertEqual(key.id, 2626761) + def testCreateSourceImport(self): + import_repo = self.g.get_user("brix4dayz").get_repo("source-import-test") + source_import = import_repo.create_source_import("mercurial", "https://bitbucket.org/hfuss/source-import-test") + self.assertEqual(source_import.authors_count, 0) + self.assertEqual(source_import.authors_url, "https://api.github.com/repos/brix4dayz/source-import-test/import/authors") + self.assertEqual(source_import.html_url, "https://github.com/brix4dayz/source-import-test/import") + self.assertEqual(source_import.repository_url, "https://api.github.com/repos/brix4dayz/source-import-test") + self.assertEqual(source_import.status, "importing") + self.assertEqual(source_import.status_text, "Importing...") + self.assertEqual(source_import.url, "https://api.github.com/repos/brix4dayz/source-import-test/import") + self.assertEqual(source_import.vcs, "mercurial") + self.assertEqual(source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test") + def testCollaborators(self): lyloa = self.g.get_user("Lyloa") self.assertFalse(self.repo.has_in_collaborators(lyloa)) @@ -486,6 +499,23 @@ class Repository(Framework.TestCase): def testGetWatchers(self): self.assertListKeyEqual(self.repo.get_watchers(), lambda u: u.login, ["Stals", "att14", "jardon-u", "huxley", "mikofski", "L42y", "fanzeyi", "abersager", "waylan", "adericbourg", "tallforasmurf", "pvicente", "roskakori", "michaelpedersen", "BeaverSoftware"]) + def testGetSourceImport(self): + import_repo = self.g.get_user("brix4dayz").get_repo("source-import-test") + source_import = import_repo.get_source_import() + self.assertEqual(source_import.authors_count, 1) + self.assertEqual(source_import.authors_url, "https://api.github.com/repos/brix4dayz/source-import-test/import/authors") + self.assertEqual(source_import.has_large_files, False) + self.assertEqual(source_import.html_url, "https://github.com/brix4dayz/source-import-test/import") + self.assertEqual(source_import.large_files_count, 0) + self.assertEqual(source_import.large_files_size, 0) + self.assertEqual(source_import.repository_url, "https://api.github.com/repos/brix4dayz/source-import-test") + self.assertEqual(source_import.status, "complete") + self.assertEqual(source_import.status_text, "Done") + self.assertEqual(source_import.url, "https://api.github.com/repos/brix4dayz/source-import-test/import") + self.assertEqual(source_import.use_lfs, "undecided") + self.assertEqual(source_import.vcs, "mercurial") + self.assertEqual(source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test") + def testGetStargazers(self): self.assertListKeyEqual(self.repo.get_stargazers(), lambda u: u.login, ["Stals", "att14", "jardon-u", "huxley", "mikofski", "L42y", "fanzeyi", "abersager", "waylan", "adericbourg", "tallforasmurf", "pvicente", "roskakori", "michaelpedersen", "stefanfoulis", "equus12", "JuRogn", "joshmoore", "jsilter", "dasapich", "ritratt", "hcilab", "vxnick", "pmuilu", "herlo", "malexw", "ahmetvurgun", "PengGu", "cosmin", "Swop", "kennethreitz", "bryandyck", "jason2506", "zsiciarz", "waawal", "gregorynicholas", "sente", "richmiller55", "thouis", "mazubieta", "michaelhood", "engie", "jtriley", "oangeor", "coryking", "noddi", "alejo8591", "omab", "Carreau", "bilderbuchi", "schwa", "rlerallut", "PengHub", "zoek1", "xobb1t", "notgary", "hattya", "ZebtinRis", "aaronhall", "youngsterxyf", "ailling", "gregwjacobs", "n0rmrx", "awylie", "firstthumb", "joshbrand", "berndca"]) diff --git a/github/tests/SourceImport.py b/github/tests/SourceImport.py new file mode 100644 index 00000000..30a8920f --- /dev/null +++ b/github/tests/SourceImport.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +# ########################## Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +# ############################################################################## + +import Framework + + +class SourceImport(Framework.TestCase): + def setUp(self): + Framework.TestCase.setUp(self) + self.user = self.g.get_user("brix4dayz") + self.repo = self.user.get_repo("source-import-test") + self.source_import = self.repo.get_source_import() + + def testAttributes(self): + self.assertEqual(self.source_import.authors_count, 1) + self.assertEqual(self.source_import.authors_url, "https://api.github.com/repos/brix4dayz/source-import-test/import/authors") + self.assertEqual(self.source_import.has_large_files, False) + self.assertEqual(self.source_import.html_url, "https://github.com/brix4dayz/source-import-test/import") + self.assertEqual(self.source_import.large_files_count, 0) + self.assertEqual(self.source_import.large_files_size, 0) + self.assertEqual(self.source_import.repository_url, "https://api.github.com/repos/brix4dayz/source-import-test") + self.assertEqual(self.source_import.status, "complete") + self.assertEqual(self.source_import.status_text, "Done") + self.assertEqual(self.source_import.url, "https://api.github.com/repos/brix4dayz/source-import-test/import") + self.assertEqual(self.source_import.use_lfs, "undecided") + self.assertEqual(self.source_import.vcs, "mercurial") + self.assertEqual(self.source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test") + + self.assertEqual(self.source_import.__repr__(), + 'SourceImport(vcs_url="https://bitbucket.org/hfuss/source-import-test", url="https://api.github.com/repos/brix4dayz/source-import-test/import", status="complete", repository_url="https://api.github.com/repos/brix4dayz/source-import-test")')