/ tests / PublicKey.py
PublicKey.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 Jannis Gebauer <ja.geb@me.com>                                #
 8  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 9  # Copyright 2017 Simon <spam@esemi.ru>                                         #
10  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
11  #                                                                              #
12  # This file is part of PyGithub.                                               #
13  # http://pygithub.readthedocs.io/                                              #
14  #                                                                              #
15  # PyGithub is free software: you can redistribute it and/or modify it under    #
16  # the terms of the GNU Lesser General Public License as published by the Free  #
17  # Software Foundation, either version 3 of the License, or (at your option)    #
18  # any later version.                                                           #
19  #                                                                              #
20  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
21  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
22  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
23  # details.                                                                     #
24  #                                                                              #
25  # You should have received a copy of the GNU Lesser General Public License     #
26  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
27  #                                                                              #
28  ################################################################################
29  
30  from . import Framework
31  
32  
33  class PublicKey(Framework.TestCase):
34      def testAttributes(self):
35          self.public_key = self.g.get_user().get_repo("PyGithub").get_public_key()
36          self.assertEqual(self.public_key.key, "u5e1Z25+z8pmgVVt5Pd8k0z/sKpVL1MXYtRAecE4vm8=")
37          self.assertEqual(self.public_key.key_id, "568250167242549743")
38          self.assertEqual(
39              repr(self.public_key),
40              'PublicKey(key_id="568250167242549743", key="u5e1Z25+z8pmgVVt5Pd8k0z/sKpVL1MXYtRAecE4vm8=")',
41          )
42  
43      def testAttributes_with_int_key_id(self):
44          self.public_key = self.g.get_user().get_repo("PyGithub").get_public_key()
45          self.assertEqual(self.public_key.key, "u5e1Z25+z8pmgVVt5Pd8k0z/sKpVL1MXYtRAecE4vm8=")
46          self.assertEqual(self.public_key.key_id, 568250167242549743)
47          self.assertEqual(
48              repr(self.public_key),
49              'PublicKey(key_id=568250167242549743, key="u5e1Z25+z8pmgVVt5Pd8k0z/sKpVL1MXYtRAecE4vm8=")',
50          )