GitCommit.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 datetime import datetime, timezone 31 32 from . import Framework 33 34 35 class GitCommit(Framework.TestCase): 36 def setUp(self): 37 super().setUp() 38 self.commit = self.g.get_user().get_repo("PyGithub").get_git_commit("4303c5b90e2216d927155e9609436ccb8984c495") 39 40 def testAttributes(self): 41 self.assertEqual(self.commit.author.name, "Vincent Jacques") 42 self.assertEqual(self.commit.author.email, "vincent@vincent-jacques.net") 43 self.assertEqual( 44 self.commit.author.date, 45 datetime(2012, 4, 17, 17, 55, 16, tzinfo=timezone.utc), 46 ) 47 self.assertEqual(self.commit.committer.name, "Vincent Jacques") 48 self.assertEqual(self.commit.committer.email, "vincent@vincent-jacques.net") 49 self.assertEqual( 50 self.commit.committer.date, 51 datetime(2012, 4, 17, 17, 55, 16, tzinfo=timezone.utc), 52 ) 53 self.assertEqual(self.commit.message, "Merge branch 'develop'\n") 54 self.assertEqual(len(self.commit.parents), 2) 55 self.assertEqual(self.commit.parents[0].sha, "936f4a97f1a86392637ec002bbf89ff036a5062d") 56 self.assertEqual(self.commit.parents[1].sha, "2a7e80e6421c5d4d201d60619068dea6bae612cb") 57 self.assertEqual(self.commit.sha, "4303c5b90e2216d927155e9609436ccb8984c495") 58 self.assertEqual(self.commit.tree.sha, "f492784d8ca837779650d1fb406a1a3587a764ad") 59 self.assertEqual( 60 self.commit.url, 61 "https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495", 62 ) 63 self.assertEqual( 64 repr(self.commit), 65 'GitCommit(sha="4303c5b90e2216d927155e9609436ccb8984c495")', 66 ) 67 self.assertEqual(repr(self.commit.author), 'GitAuthor(name="Vincent Jacques")')