/ tests / Equality.py
Equality.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
 4  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
 5  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 6  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 7  #                                                                              #
 8  # This file is part of PyGithub.                                               #
 9  # http://pygithub.readthedocs.io/                                              #
10  #                                                                              #
11  # PyGithub is free software: you can redistribute it and/or modify it under    #
12  # the terms of the GNU Lesser General Public License as published by the Free  #
13  # Software Foundation, either version 3 of the License, or (at your option)    #
14  # any later version.                                                           #
15  #                                                                              #
16  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
17  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
18  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
19  # details.                                                                     #
20  #                                                                              #
21  # You should have received a copy of the GNU Lesser General Public License     #
22  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
23  #                                                                              #
24  ################################################################################
25  
26  from . import Framework
27  
28  
29  class Equality(Framework.TestCase):
30      def testUserEquality(self):
31          u1 = self.g.get_user("jacquev6")
32          u2 = self.g.get_user("jacquev6")
33          self.assertEqual(u1, u2)
34          self.assertEqual(hash(u1), hash(u2))
35  
36      def testUserDifference(self):
37          u1 = self.g.get_user("jacquev6")
38          u2 = self.g.get_user("OddBloke")
39          self.assertNotEqual(u1, u2)
40          self.assertNotEqual(hash(u1), hash(u2))
41  
42      def testBranchEquality(self):
43          # Erf, equality of NonCompletableGithubObjects will be difficult to implement
44          # because even their _rawData can differ. (Here, the avatar_url is not equal)
45          # (CompletableGithubObjects are compared by their API url, which is a good key)
46          r = self.g.get_user().get_repo("PyGithub")
47          b1 = r.get_branch("develop")
48          b2 = r.get_branch("develop")
49          self.assertNotEqual(b1._rawData, b2._rawData)