/ tests / Issue945.py
Issue945.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2018 Kelvin Wong (https://github.com/netsgnut)                     #
 4  #                                                                              #
 5  # This file is part of PyGithub.                                               #
 6  # http://pygithub.readthedocs.io/                                              #
 7  #                                                                              #
 8  # PyGithub is free software: you can redistribute it and/or modify it under    #
 9  # the terms of the GNU Lesser General Public License as published by the Free  #
10  # Software Foundation, either version 3 of the License, or (at your option)    #
11  # any later version.                                                           #
12  #                                                                              #
13  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
14  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
15  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
16  # details.                                                                     #
17  #                                                                              #
18  # You should have received a copy of the GNU Lesser General Public License     #
19  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
20  #                                                                              #
21  ################################################################################
22  
23  from . import Framework
24  
25  
26  class Issue945(Framework.TestCase):  # https://github.com/PyGithub/PyGithub/issues/945
27      def setUp(self):
28          super().setUp()
29          self.repo = self.g.get_user("openframeworks").get_repo("openFrameworks")
30          self.list = self.repo.get_issues()
31          self.list_with_headers = self.repo.get_stargazers_with_dates()
32  
33      def testReservedPaginatedListAttributePreservation(self):
34          r1 = self.list.reversed
35          self.assertEqual(self.list._PaginatedList__contentClass, r1._PaginatedList__contentClass)
36          self.assertEqual(self.list._PaginatedList__requester, r1._PaginatedList__requester)
37          self.assertEqual(self.list._PaginatedList__firstUrl, r1._PaginatedList__firstUrl)
38          self.assertEqual(self.list._PaginatedList__firstParams, r1._PaginatedList__firstParams)
39          self.assertEqual(self.list._PaginatedList__headers, r1._PaginatedList__headers)
40          self.assertEqual(self.list._PaginatedList__list_item, r1._PaginatedList__list_item)
41  
42          self.assertTrue(self.list_with_headers._PaginatedList__headers is not None)
43          r2 = self.list_with_headers.reversed
44          self.assertEqual(
45              self.list_with_headers._PaginatedList__contentClass,
46              r2._PaginatedList__contentClass,
47          )
48          self.assertEqual(
49              self.list_with_headers._PaginatedList__requester,
50              r2._PaginatedList__requester,
51          )
52          self.assertEqual(self.list_with_headers._PaginatedList__firstUrl, r2._PaginatedList__firstUrl)
53          self.assertEqual(
54              self.list_with_headers._PaginatedList__firstParams,
55              r2._PaginatedList__firstParams,
56          )
57          self.assertEqual(self.list_with_headers._PaginatedList__headers, r2._PaginatedList__headers)
58          self.assertEqual(
59              self.list_with_headers._PaginatedList__list_item,
60              r2._PaginatedList__list_item,
61          )