/ tests / Issue80.py
Issue80.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net>                 #
 4  # Copyright 2012 Zearin <zearin@gonk.net>                                      #
 5  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
 6  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
 7  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 8  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 9  #                                                                              #
10  # This file is part of PyGithub.                                               #
11  # http://pygithub.readthedocs.io/                                              #
12  #                                                                              #
13  # PyGithub is free software: you can redistribute it and/or modify it under    #
14  # the terms of the GNU Lesser General Public License as published by the Free  #
15  # Software Foundation, either version 3 of the License, or (at your option)    #
16  # any later version.                                                           #
17  #                                                                              #
18  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
19  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
20  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
21  # details.                                                                     #
22  #                                                                              #
23  # You should have received a copy of the GNU Lesser General Public License     #
24  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
25  #                                                                              #
26  ################################################################################
27  
28  import github
29  
30  from . import Framework
31  
32  
33  class Issue80(Framework.BasicTestCase):  # https://github.com/jacquev6/PyGithub/issues/80
34      def testIgnoreHttpsFromGithubEnterprise(self):
35          g = github.Github(auth=self.login, base_url="http://my.enterprise.com/some/prefix")  # http here
36          org = g.get_organization("BeaverSoftware")
37          self.assertEqual(org.url, "https://my.enterprise.com/some/prefix/orgs/BeaverSoftware")  # https returned
38          self.assertListKeyEqual(
39              org.get_repos(), lambda r: r.name, ["FatherBeaver", "TestPyGithub"]
40          )  # But still http in second request based on org.url
41  
42      def testIgnoreHttpsFromGithubEnterpriseWithPort(self):
43          g = github.Github(
44              auth=self.login,
45              base_url="http://my.enterprise.com:1234/some/prefix",
46          )  # http here
47          org = g.get_organization("BeaverSoftware")
48          self.assertEqual(org.url, "https://my.enterprise.com:1234/some/prefix/orgs/BeaverSoftware")  # https returned
49          self.assertListKeyEqual(
50              org.get_repos(), lambda r: r.name, ["FatherBeaver", "TestPyGithub"]
51          )  # But still http in second request based on org.url