mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
committed by
Wan Liuyang
parent
cd6d56d60a
commit
b4d895eddd
@@ -91,6 +91,7 @@ from Tag import *
|
||||
from Team import *
|
||||
from Traffic import *
|
||||
from UserKey import *
|
||||
from Migration import *
|
||||
|
||||
from PaginatedList import *
|
||||
from Exceptions import *
|
||||
|
||||
@@ -251,3 +251,9 @@ class AuthenticatedUser(Framework.TestCase):
|
||||
|
||||
def testAcceptInvitation(self):
|
||||
self.assertEqual(self.user.accept_invitation(4294886), None)
|
||||
|
||||
def testCreateMigration(self):
|
||||
self.assertTrue(isinstance(self.user.create_migration(["sample-repo"]), github.Migration.Migration))
|
||||
|
||||
def testGetMigrations(self):
|
||||
self.assertEqual(self.user.get_migrations().totalCount, 46)
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################ Copyrights and license ############################
|
||||
# #
|
||||
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2012 Zearin <zearin@gonk.net> #
|
||||
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2015 Christopher Wilcox <git@crwilcox.com> #
|
||||
# Copyright 2015 Dan Vanderkam <danvdk@gmail.com> #
|
||||
# Copyright 2015 Enix Yu <enix223@163.com> #
|
||||
# Copyright 2015 Kyle Hornberg <khornberg@users.noreply.github.com> #
|
||||
# Copyright 2015 Uriel Corfa <uriel@corfa.fr> #
|
||||
# Copyright 2016 @tmshn <tmshn@r.recruit.co.jp> #
|
||||
# Copyright 2016 Enix Yu <enix223@163.com> #
|
||||
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2016 Jimmy Zelinskie <jimmyzelinskie@gmail.com> #
|
||||
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
||||
# Copyright 2018 Hayden Fuss <wifu1234@gmail.com> #
|
||||
# Copyright 2018 Iraquitan Cordeiro Filho <iraquitanfilho@gmail.com> #
|
||||
# Copyright 2018 Jacopo Notarstefano <jacopo.notarstefano@gmail.com> #
|
||||
# Copyright 2018 Maarten Fonville <mfonville@users.noreply.github.com> #
|
||||
# Copyright 2018 Mateusz Loskot <mateusz@loskot.net> #
|
||||
# Copyright 2018 Raihaan <31362124+res0nance@users.noreply.github.com> #
|
||||
# Copyright 2018 Shinichi TAMURA <shnch.tmr@gmail.com> #
|
||||
# Copyright 2018 Steve Kowalik <steven@wedontsleep.org> #
|
||||
# Copyright 2018 Victor Granic <vmg@boreal321.com> #
|
||||
# Copyright 2018 Wan Liuyang <tsfdye@gmail.com> #
|
||||
# Copyright 2018 Will Yardley <wyardley@users.noreply.github.com> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# #
|
||||
# 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 <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
import Framework
|
||||
|
||||
import github
|
||||
import datetime
|
||||
|
||||
class Migration(Framework.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
Framework.TestCase.setUp(self)
|
||||
self.user = self.g.get_user()
|
||||
self.migration = self.user.get_migrations()[0]
|
||||
|
||||
def testAttributes(self):
|
||||
self.assertEqual(self.migration.id, 25320)
|
||||
self.assertEqual(self.migration.owner.login, "singh811")
|
||||
self.assertEqual(self.migration.guid, "608bceae-b790-11e8-8b43-4e3cb0dd56cc")
|
||||
self.assertEqual(self.migration.state, "exported")
|
||||
self.assertEqual(self.migration.lock_repositories, False)
|
||||
self.assertEqual(self.migration.exclude_attachments, False)
|
||||
self.assertEqual(len(self.migration.repositories), 1)
|
||||
self.assertEqual(self.migration.repositories[0].name, "sample-repo")
|
||||
self.assertEqual(self.migration.url, "https://api.github.com/user/migrations/25320")
|
||||
self.assertEqual(self.migration.created_at, datetime.datetime(2018, 9, 14, 1, 35, 35))
|
||||
self.assertEqual(self.migration.updated_at, datetime.datetime(2018, 9, 14, 1, 35, 46))
|
||||
|
||||
def testGetArchiveUrlWhenNotExported(self):
|
||||
self.assertRaises(github.UnknownObjectException, lambda: self.migration.get_archive_url())
|
||||
|
||||
def testGetStatus(self):
|
||||
self.assertEqual(self.migration.get_status(), "exported")
|
||||
|
||||
def testGetArchiveUrlWhenExported(self):
|
||||
self.assertEqual(self.migration.get_archive_url(), "https://github-cloud.s3.amazonaws.com/migration/25320/24575?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20180913%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180913T201100Z&X-Amz-Expires=300&X-Amz-Signature=a0aeb638facd0c78c1ed3ca86022eddbee91e5fe1bb48ee830f54b8b7b305026&X-Amz-SignedHeaders=host&actor_id=41840111&response-content-disposition=filename%3D608bceae-b790-11e8-8b43-4e3cb0dd56cc.tar.gz&response-content-type=application%2Fx-gzip")
|
||||
|
||||
def testDelete(self):
|
||||
self.assertEqual(self.migration.delete(), None)
|
||||
|
||||
def testGetArchiveUrlWhenDeleted(self):
|
||||
self.assertRaises(github.UnknownObjectException, lambda: self.migration.get_archive_url())
|
||||
|
||||
def testUnlockRepo(self):
|
||||
self.assertEqual(self.migration.unlock_repo("sample-repo"), None)
|
||||
@@ -247,3 +247,11 @@ class Organization(Framework.TestCase):
|
||||
u'message': u'You must be an admin to create an invitation to an organization.'
|
||||
}
|
||||
)
|
||||
|
||||
def testCreateMigration(self):
|
||||
self.org = self.g.get_organization("sample-test-organisation")
|
||||
self.assertTrue(isinstance(self.org.create_migration(["sample-repo"]), github.Migration.Migration))
|
||||
|
||||
def testGetMigrations(self):
|
||||
self.org = self.g.get_organization("sample-test-organisation")
|
||||
self.assertEqual(self.org.get_migrations().totalCount, 2)
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/user/migrations/25320/archive
|
||||
{'Accept': 'application/vnd.github.wyandotte-preview+json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
204
|
||||
[('Server', 'GitHub.com'), ('Date', 'Thu, 13 Sep 2018 20:14:05 GMT'), ('Content-Type', 'application/octet-stream'), ('Status', '204 No Content'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4971'), ('X-RateLimit-Reset', '1536871398'), ('X-GitHub-Media-Type', 'github.wyandotte-preview; 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'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('X-Runtime-rack', '0.083770'), ('X-GitHub-Request-Id', 'F9FA:20FB:A7EA64:165BB04:5B9AC50C')]
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/user/migrations/25320/archive
|
||||
{'Accept': 'application/vnd.github.wyandotte-preview+json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
404
|
||||
[('Server', 'GitHub.com'), ('Date', 'Thu, 13 Sep 2018 20:17:43 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Status', '404 Not Found'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4969'), ('X-RateLimit-Reset', '1536871398'), ('X-GitHub-Media-Type', 'github.wyandotte-preview; 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'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('X-Runtime-rack', '0.048286'), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'D06B:20FA:80A9D5:128E928:5B9AC5E6')]
|
||||
{"message":"Not Found","documentation_url":"https://developer.github.com/v3/migrations/users/#download-a-user-migration-archive"}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/user/migrations/25320/archive
|
||||
{'Accept': 'application/vnd.github.wyandotte-preview+json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
302
|
||||
[('Server', 'GitHub.com'), ('Date', 'Thu, 13 Sep 2018 20:11:00 GMT'), ('Content-Type', 'text/html;charset=utf-8'), ('Content-Length', '470'), ('Status', '302 Found'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4976'), ('X-RateLimit-Reset', '1536871398'), ('location', 'https://github-cloud.s3.amazonaws.com/migration/25320/24575?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20180913%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180913T201100Z&X-Amz-Expires=300&X-Amz-Signature=a0aeb638facd0c78c1ed3ca86022eddbee91e5fe1bb48ee830f54b8b7b305026&X-Amz-SignedHeaders=host&actor_id=41840111&response-content-disposition=filename%3D608bceae-b790-11e8-8b43-4e3cb0dd56cc.tar.gz&response-content-type=application%2Fx-gzip'), ('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'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('X-Runtime-rack', '0.066845'), ('X-GitHub-Request-Id', '72DA:20F9:4DC6B3:C7706A:5B9AC453')]
|
||||
https://github-cloud.s3.amazonaws.com/migration/25320/24575?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20180913%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180913T201100Z&X-Amz-Expires=300&X-Amz-Signature=a0aeb638facd0c78c1ed3ca86022eddbee91e5fe1bb48ee830f54b8b7b305026&X-Amz-SignedHeaders=host&actor_id=41840111&response-content-disposition=filename%3D608bceae-b790-11e8-8b43-4e3cb0dd56cc.tar.gz&response-content-type=application%2Fx-gzip
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/user/migrations/25320/archive
|
||||
{'Accept': 'application/vnd.github.wyandotte-preview+json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
404
|
||||
[('Server', 'GitHub.com'), ('Date', 'Thu, 13 Sep 2018 20:05:39 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Status', '404 Not Found'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4978'), ('X-RateLimit-Reset', '1536871398'), ('X-GitHub-Media-Type', 'github.wyandotte-preview; 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'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('X-Runtime-rack', '0.047402'), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', '87CF:20FB:A75E84:1648F66:5B9AC312')]
|
||||
{"message":"Not Found","documentation_url":"https://developer.github.com/v3/migrations/users/#download-a-user-migration-archive"}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/user/migrations/25320/repos/sample-repo/lock
|
||||
{'Accept': 'application/vnd.github.wyandotte-preview+json', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
204
|
||||
[('Server', 'GitHub.com'), ('Date', 'Thu, 13 Sep 2018 20:18:24 GMT'), ('Content-Type', 'application/octet-stream'), ('Status', '204 No Content'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4966'), ('X-RateLimit-Reset', '1536871398'), ('X-GitHub-Media-Type', 'github.wyandotte-preview; 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'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('X-Runtime-rack', '0.123605'), ('X-GitHub-Request-Id', '1EA2:20FA:80B1CA:128FAE1:5B9AC610')]
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user