Skip to content

Commit 60a684c

Browse files
netsgnutsfdye
authored andcommitted
Added missing params to constructor when reversed (PyGithub#946)
This PR proposes adding two missing params to constructor in `.reversed`. This preserves the `headers` as well as the `list_item` once cloned. Fixes PyGithub#945.
1 parent 972446d commit 60a684c

5 files changed

+99
-1
lines changed

github/PaginatedList.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _getLastPageUrl(self):
175175

176176
@property
177177
def reversed(self):
178-
r = PaginatedList(self.__contentClass, self.__requester, self.__firstUrl, self.__firstParams)
178+
r = PaginatedList(self.__contentClass, self.__requester, self.__firstUrl, self.__firstParams, self.__headers, self.__list_item)
179179
r.__reverse()
180180
return r
181181

github/tests/AllTests.py

+1
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,4 @@
122122
from Issue494 import *
123123
from Issue572 import *
124124
from Issue937 import *
125+
from Issue945 import *

github/tests/Issue945.py

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# -*- coding: utf-8 -*-
2+
3+
############################ Copyrights and license ############################
4+
# #
5+
# Copyright 2018 Kelvin Wong (https://github.com/netsgnut) #
6+
# #
7+
# This file is part of PyGithub. #
8+
# http://pygithub.readthedocs.io/ #
9+
# #
10+
# PyGithub is free software: you can redistribute it and/or modify it under #
11+
# the terms of the GNU Lesser General Public License as published by the Free #
12+
# Software Foundation, either version 3 of the License, or (at your option) #
13+
# any later version. #
14+
# #
15+
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
16+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
17+
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
18+
# details. #
19+
# #
20+
# You should have received a copy of the GNU Lesser General Public License #
21+
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
22+
# #
23+
################################################################################
24+
25+
import Framework
26+
27+
import github
28+
29+
30+
class Issue945(Framework.TestCase): # https://github.com/PyGithub/PyGithub/issues/945
31+
def setUp(self):
32+
Framework.TestCase.setUp(self)
33+
self.repo = self.g.get_user("openframeworks").get_repo("openFrameworks")
34+
self.list = self.repo.get_issues()
35+
self.list_with_headers = self.repo.get_stargazers_with_dates()
36+
37+
def testReservedPaginatedListAttributePreservation(self):
38+
r1 = self.list.reversed
39+
self.assertEqual(self.list._PaginatedList__contentClass, r1._PaginatedList__contentClass)
40+
self.assertEqual(self.list._PaginatedList__requester, r1._PaginatedList__requester)
41+
self.assertEqual(self.list._PaginatedList__firstUrl, r1._PaginatedList__firstUrl)
42+
self.assertEqual(self.list._PaginatedList__firstParams, r1._PaginatedList__firstParams)
43+
self.assertEqual(self.list._PaginatedList__headers, r1._PaginatedList__headers)
44+
self.assertEqual(self.list._PaginatedList__list_item, r1._PaginatedList__list_item)
45+
46+
self.assertTrue(self.list_with_headers._PaginatedList__headers is not None)
47+
r2 = self.list_with_headers.reversed
48+
self.assertEqual(self.list_with_headers._PaginatedList__contentClass, r2._PaginatedList__contentClass)
49+
self.assertEqual(self.list_with_headers._PaginatedList__requester, r2._PaginatedList__requester)
50+
self.assertEqual(self.list_with_headers._PaginatedList__firstUrl, r2._PaginatedList__firstUrl)
51+
self.assertEqual(self.list_with_headers._PaginatedList__firstParams, r2._PaginatedList__firstParams)
52+
self.assertEqual(self.list_with_headers._PaginatedList__headers, r2._PaginatedList__headers)
53+
self.assertEqual(self.list_with_headers._PaginatedList__list_item, r2._PaginatedList__list_item)
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
https
2+
GET
3+
api.github.com
4+
None
5+
/users/openframeworks
6+
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
7+
None
8+
200
9+
[('Server', 'GitHub.com'), ('Date', 'Fri, 26 Oct 2018 06:02:39 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Status', '200 OK'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4973'), ('X-RateLimit-Reset', '1540536267'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('ETag', 'W/"490a721bce7bb5817a38a53711404075"'), ('Last-Modified', 'Wed, 18 Nov 2015 16:33:25 GMT'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('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'), ('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'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'ED32:235D:2CFA30:625A06:5BD2ADFE')]
10+
{"login":"openframeworks","id":142866,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0Mjg2Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/142866?v=4","gravatar_id":"","url":"https://api.github.com/users/openframeworks","html_url":"https://github.com/openframeworks","followers_url":"https://api.github.com/users/openframeworks/followers","following_url":"https://api.github.com/users/openframeworks/following{/other_user}","gists_url":"https://api.github.com/users/openframeworks/gists{/gist_id}","starred_url":"https://api.github.com/users/openframeworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openframeworks/subscriptions","organizations_url":"https://api.github.com/users/openframeworks/orgs","repos_url":"https://api.github.com/users/openframeworks/repos","events_url":"https://api.github.com/users/openframeworks/events{/privacy}","received_events_url":"https://api.github.com/users/openframeworks/received_events","type":"Organization","site_admin":false,"name":"openFrameworks","company":null,"blog":"http://openframeworks.cc/","location":null,"email":null,"hireable":null,"bio":null,"public_repos":9,"public_gists":0,"followers":0,"following":0,"created_at":"2009-10-21T21:54:37Z","updated_at":"2015-11-18T16:33:25Z"}
11+
12+
https
13+
GET
14+
api.github.com
15+
None
16+
/repos/openframeworks/openFrameworks
17+
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
18+
None
19+
200
20+
[('Server', 'GitHub.com'), ('Date', 'Fri, 26 Oct 2018 06:02:40 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Status', '200 OK'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4972'), ('X-RateLimit-Reset', '1540536267'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('ETag', 'W/"501068d9a3e67fb624ce5e83e1270d41"'), ('Last-Modified', 'Fri, 26 Oct 2018 04:18:01 GMT'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', 'repo'), ('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'), ('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'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'ACCA:235E:3C0006:7729D5:5BD2ADFF')]
21+
{"id":345337,"node_id":"MDEwOlJlcG9zaXRvcnkzNDUzMzc=","name":"openFrameworks","full_name":"openframeworks/openFrameworks","private":false,"owner":{"login":"openframeworks","id":142866,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0Mjg2Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/142866?v=4","gravatar_id":"","url":"https://api.github.com/users/openframeworks","html_url":"https://github.com/openframeworks","followers_url":"https://api.github.com/users/openframeworks/followers","following_url":"https://api.github.com/users/openframeworks/following{/other_user}","gists_url":"https://api.github.com/users/openframeworks/gists{/gist_id}","starred_url":"https://api.github.com/users/openframeworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openframeworks/subscriptions","organizations_url":"https://api.github.com/users/openframeworks/orgs","repos_url":"https://api.github.com/users/openframeworks/repos","events_url":"https://api.github.com/users/openframeworks/events{/privacy}","received_events_url":"https://api.github.com/users/openframeworks/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/openframeworks/openFrameworks","description":"openFrameworks is a community-developed cross platform toolkit for creative coding in C++.","fork":false,"url":"https://api.github.com/repos/openframeworks/openFrameworks","forks_url":"https://api.github.com/repos/openframeworks/openFrameworks/forks","keys_url":"https://api.github.com/repos/openframeworks/openFrameworks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openframeworks/openFrameworks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openframeworks/openFrameworks/teams","hooks_url":"https://api.github.com/repos/openframeworks/openFrameworks/hooks","issue_events_url":"https://api.github.com/repos/openframeworks/openFrameworks/issues/events{/number}","events_url":"https://api.github.com/repos/openframeworks/openFrameworks/events","assignees_url":"https://api.github.com/repos/openframeworks/openFrameworks/assignees{/user}","branches_url":"https://api.github.com/repos/openframeworks/openFrameworks/branches{/branch}","tags_url":"https://api.github.com/repos/openframeworks/openFrameworks/tags","blobs_url":"https://api.github.com/repos/openframeworks/openFrameworks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openframeworks/openFrameworks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openframeworks/openFrameworks/git/refs{/sha}","trees_url":"https://api.github.com/repos/openframeworks/openFrameworks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openframeworks/openFrameworks/statuses/{sha}","languages_url":"https://api.github.com/repos/openframeworks/openFrameworks/languages","stargazers_url":"https://api.github.com/repos/openframeworks/openFrameworks/stargazers","contributors_url":"https://api.github.com/repos/openframeworks/openFrameworks/contributors","subscribers_url":"https://api.github.com/repos/openframeworks/openFrameworks/subscribers","subscription_url":"https://api.github.com/repos/openframeworks/openFrameworks/subscription","commits_url":"https://api.github.com/repos/openframeworks/openFrameworks/commits{/sha}","git_commits_url":"https://api.github.com/repos/openframeworks/openFrameworks/git/commits{/sha}","comments_url":"https://api.github.com/repos/openframeworks/openFrameworks/comments{/number}","issue_comment_url":"https://api.github.com/repos/openframeworks/openFrameworks/issues/comments{/number}","contents_url":"https://api.github.com/repos/openframeworks/openFrameworks/contents/{+path}","compare_url":"https://api.github.com/repos/openframeworks/openFrameworks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openframeworks/openFrameworks/merges","archive_url":"https://api.github.com/repos/openframeworks/openFrameworks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openframeworks/openFrameworks/downloads","issues_url":"https://api.github.com/repos/openframeworks/openFrameworks/issues{/number}","pulls_url":"https://api.github.com/repos/openframeworks/openFrameworks/pulls{/number}","milestones_url":"https://api.github.com/repos/openframeworks/openFrameworks/milestones{/number}","notifications_url":"https://api.github.com/repos/openframeworks/openFrameworks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openframeworks/openFrameworks/labels{/name}","releases_url":"https://api.github.com/repos/openframeworks/openFrameworks/releases{/id}","deployments_url":"https://api.github.com/repos/openframeworks/openFrameworks/deployments","created_at":"2009-10-21T21:55:54Z","updated_at":"2018-10-26T04:18:01Z","pushed_at":"2018-10-18T15:56:59Z","git_url":"git://github.com/openframeworks/openFrameworks.git","ssh_url":"[email protected]:openframeworks/openFrameworks.git","clone_url":"https://github.com/openframeworks/openFrameworks.git","svn_url":"https://github.com/openframeworks/openFrameworks","homepage":"http://openframeworks.cc","size":1997625,"stargazers_count":6453,"watchers_count":6453,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2143,"mirror_url":null,"archived":false,"open_issues_count":874,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2143,"open_issues":874,"watchers":6453,"default_branch":"patch-release","permissions":{"admin":false,"push":false,"pull":true},"organization":{"login":"openframeworks","id":142866,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0Mjg2Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/142866?v=4","gravatar_id":"","url":"https://api.github.com/users/openframeworks","html_url":"https://github.com/openframeworks","followers_url":"https://api.github.com/users/openframeworks/followers","following_url":"https://api.github.com/users/openframeworks/following{/other_user}","gists_url":"https://api.github.com/users/openframeworks/gists{/gist_id}","starred_url":"https://api.github.com/users/openframeworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openframeworks/subscriptions","organizations_url":"https://api.github.com/users/openframeworks/orgs","repos_url":"https://api.github.com/users/openframeworks/repos","events_url":"https://api.github.com/users/openframeworks/events{/privacy}","received_events_url":"https://api.github.com/users/openframeworks/received_events","type":"Organization","site_admin":false},"network_count":2143,"subscribers_count":514}
22+

github/tests/ReplayData/Issue945.testReservedPaginatedListAttributePreservation.txt

+22
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)