CommitComment.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 Nicolas AgustÃn Torres <nicolastrres@gmail.com> # 10 # Copyright 2018 sfdye <tsfdye@gmail.com> # 11 # Copyright 2020 Huan-Cheng Chang <changhc84@gmail.com> # 12 # # 13 # This file is part of PyGithub. # 14 # http://pygithub.readthedocs.io/ # 15 # # 16 # PyGithub is free software: you can redistribute it and/or modify it under # 17 # the terms of the GNU Lesser General Public License as published by the Free # 18 # Software Foundation, either version 3 of the License, or (at your option) # 19 # any later version. # 20 # # 21 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 22 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 23 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 24 # details. # 25 # # 26 # You should have received a copy of the GNU Lesser General Public License # 27 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 28 # # 29 ################################################################################ 30 31 from datetime import datetime, timezone 32 33 from . import Framework 34 35 36 class CommitComment(Framework.TestCase): 37 def setUp(self): 38 super().setUp() 39 self.comment = self.g.get_user().get_repo("PyGithub").get_comment(1361949) 40 41 def testAttributes(self): 42 self.assertEqual(self.comment.body, "Comment created by PyGithub") 43 self.assertEqual(self.comment.commit_id, "6945921c529be14c3a8f566dd1e483674516d46d") 44 self.assertEqual( 45 self.comment.created_at, 46 datetime(2012, 5, 22, 18, 40, 18, tzinfo=timezone.utc), 47 ) 48 self.assertEqual( 49 self.comment.html_url, 50 "https://github.com/jacquev6/PyGithub/commit/6945921c529be14c3a8f566dd1e483674516d46d#commitcomment-1361949", 51 ) 52 self.assertEqual(self.comment.id, 1361949) 53 self.assertEqual(self.comment.line, None) 54 self.assertEqual(self.comment.path, None) 55 self.assertEqual(self.comment.position, None) 56 self.assertEqual( 57 self.comment.updated_at, 58 datetime(2012, 5, 22, 18, 40, 18, tzinfo=timezone.utc), 59 ) 60 self.assertEqual( 61 self.comment.url, 62 "https://api.github.com/repos/jacquev6/PyGithub/comments/1361949", 63 ) 64 self.assertEqual(self.comment.user.login, "jacquev6") 65 self.assertEqual( 66 repr(self.comment), 67 'CommitComment(user=NamedUser(login="jacquev6"), id=1361949)', 68 ) 69 70 def testEdit(self): 71 self.comment.edit("Comment edited by PyGithub") 72 73 def testDelete(self): 74 self.comment.delete() 75 76 def testGetReactions(self): 77 reactions = self.comment.get_reactions() 78 self.assertEqual(reactions[0].content, "+1") 79 80 def testCreateReaction(self): 81 reaction = self.comment.create_reaction("hooray") 82 83 self.assertEqual(reaction.id, 17283092) 84 self.assertEqual(reaction.content, "hooray") 85 86 def testDeleteReaction(self): 87 self.assertTrue(self.comment.delete_reaction(85737646))