GitRef.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 2018 sfdye <tsfdye@gmail.com> # 10 # # 11 # This file is part of PyGithub. # 12 # http://pygithub.readthedocs.io/ # 13 # # 14 # PyGithub is free software: you can redistribute it and/or modify it under # 15 # the terms of the GNU Lesser General Public License as published by the Free # 16 # Software Foundation, either version 3 of the License, or (at your option) # 17 # any later version. # 18 # # 19 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 20 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 21 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 22 # details. # 23 # # 24 # You should have received a copy of the GNU Lesser General Public License # 25 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 26 # # 27 ################################################################################ 28 29 from . import Framework 30 31 32 class GitRef(Framework.TestCase): 33 def setUp(self): 34 super().setUp() 35 self.ref = self.g.get_user().get_repo("PyGithub").get_git_ref("heads/BranchCreatedByPyGithub") 36 37 def testAttributes(self): 38 self.assertEqual(self.ref.object.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a") 39 self.assertEqual(self.ref.object.type, "commit") 40 self.assertEqual( 41 self.ref.object.url, 42 "https://api.github.com/repos/jacquev6/PyGithub/git/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a", 43 ) 44 self.assertEqual(self.ref.ref, "refs/heads/BranchCreatedByPyGithub") 45 self.assertEqual( 46 self.ref.url, 47 "https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub", 48 ) 49 50 self.assertEqual(repr(self.ref), 'GitRef(ref="refs/heads/BranchCreatedByPyGithub")') 51 self.assertEqual( 52 repr(self.ref.object), 53 'GitObject(sha="1292bf0e22c796e91cc3d6e24b544aece8c21f2a")', 54 ) 55 56 def testEdit(self): 57 self.ref.edit("04cde900a0775b51f762735637bd30de392a2793") 58 59 def testEditWithForce(self): 60 self.ref.edit("4303c5b90e2216d927155e9609436ccb8984c495", force=True) 61 62 def testDelete(self): 63 self.ref.delete()