/ tests / GitBlob.py
GitBlob.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 . import Framework
31  
32  
33  class GitBlob(Framework.TestCase):
34      def setUp(self):
35          super().setUp()
36          self.blob = self.g.get_user().get_repo("PyGithub").get_git_blob("53bce9fa919b4544e67275089b3ec5b44be20667")
37  
38      def testAttributes(self):
39          self.assertTrue(
40              self.blob.content.startswith(
41                  "IyEvdXNyL2Jpbi9lbnYgcHl0aG9uCgpmcm9tIGRpc3R1dGlscy5jb3JlIGlt\ncG9ydCBzZXR1cAppbXBvcnQgdGV4dHdyYXAKCnNldHVwKAogICAgbmFtZSA9\n"
42              )
43          )
44          self.assertTrue(
45              self.blob.content.endswith(
46                  "Z3JhbW1pbmcgTGFuZ3VhZ2UgOjogUHl0aG9uIiwKICAgICAgICAiVG9waWMg\nOjogU29mdHdhcmUgRGV2ZWxvcG1lbnQiLAogICAgXSwKKQo=\n"
47              )
48          )
49          self.assertEqual(len(self.blob.content), 1757)
50          self.assertEqual(self.blob.encoding, "base64")
51          self.assertEqual(self.blob.size, 1295)
52          self.assertEqual(self.blob.sha, "53bce9fa919b4544e67275089b3ec5b44be20667")
53          self.assertEqual(
54              self.blob.url,
55              "https://api.github.com/repos/jacquev6/PyGithub/git/blobs/53bce9fa919b4544e67275089b3ec5b44be20667",
56          )
57          self.assertEqual(
58              repr(self.blob),
59              'GitBlob(sha="53bce9fa919b4544e67275089b3ec5b44be20667")',
60          )