IssueComment.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 IssueComment(Framework.TestCase): 37 def setUp(self): 38 super().setUp() 39 self.comment = self.g.get_user().get_repo("PyGithub").get_issue(28).get_comment(5808311) 40 41 def testAttributes(self): 42 self.assertEqual(self.comment.body, "Comment created by PyGithub") 43 self.assertEqual( 44 self.comment.created_at, 45 datetime(2012, 5, 20, 11, 46, 42, tzinfo=timezone.utc), 46 ) 47 self.assertEqual(self.comment.id, 5808311) 48 self.assertEqual( 49 self.comment.updated_at, 50 datetime(2012, 5, 20, 11, 46, 42, tzinfo=timezone.utc), 51 ) 52 self.assertEqual( 53 self.comment.url, 54 "https://api.github.com/repos/jacquev6/PyGithub/issues/comments/5808311", 55 ) 56 self.assertEqual(self.comment.user.login, "jacquev6") 57 self.assertEqual( 58 self.comment.html_url, 59 "https://github.com/jacquev6/PyGithub/issues/28#issuecomment-5808311", 60 ) 61 self.assertEqual( 62 repr(self.comment), 63 'IssueComment(user=NamedUser(login="jacquev6"), id=5808311)', 64 ) 65 66 def testEdit(self): 67 self.comment.edit("Comment edited by PyGithub") 68 self.assertEqual(self.comment.body, "Comment edited by PyGithub") 69 self.assertEqual( 70 self.comment.updated_at, 71 datetime(2012, 5, 20, 11, 53, 59, tzinfo=timezone.utc), 72 ) 73 74 def testDelete(self): 75 self.comment.delete() 76 77 def testGetReactions(self): 78 reactions = self.comment.get_reactions() 79 self.assertEqual(reactions[0].content, "+1") 80 81 def testCreateReaction(self): 82 reaction = self.comment.create_reaction("hooray") 83 84 self.assertEqual(reaction.id, 17282654) 85 self.assertEqual(reaction.content, "hooray") 86 87 def testDeleteReaction(self): 88 self.assertTrue(self.comment.delete_reaction(85743754))