/ tests / GistComment.py
GistComment.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 datetime import datetime, timezone
30  
31  from . import Framework
32  
33  
34  class GistComment(Framework.TestCase):
35      def setUp(self):
36          super().setUp()
37          self.comment = self.g.get_gist("2729810").get_comment(323629)
38  
39      def testAttributes(self):
40          self.assertEqual(self.comment.body, "Comment created by PyGithub")
41          self.assertEqual(
42              self.comment.created_at,
43              datetime(2012, 5, 19, 7, 7, 57, tzinfo=timezone.utc),
44          )
45          self.assertEqual(self.comment.id, 323629)
46          self.assertEqual(
47              self.comment.updated_at,
48              datetime(2012, 5, 19, 7, 7, 57, tzinfo=timezone.utc),
49          )
50          self.assertEqual(self.comment.url, "https://api.github.com/gists/2729810/comments/323629")
51          self.assertEqual(self.comment.user.login, "jacquev6")
52          self.assertEqual(
53              repr(self.comment),
54              'GistComment(user=NamedUser(login="jacquev6"), id=323629)',
55          )
56  
57      def testEdit(self):
58          self.comment.edit("Comment edited by PyGithub")
59          self.assertEqual(self.comment.body, "Comment edited by PyGithub")
60          self.assertEqual(
61              self.comment.updated_at,
62              datetime(2012, 5, 19, 7, 12, 32, tzinfo=timezone.utc),
63          )
64  
65      def testDelete(self):
66          self.comment.delete()