Issue140.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # 4 # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> # 5 # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> # 6 # Copyright 2018 sfdye <tsfdye@gmail.com> # 7 # # 8 # This file is part of PyGithub. # 9 # http://pygithub.readthedocs.io/ # 10 # # 11 # PyGithub is free software: you can redistribute it and/or modify it under # 12 # the terms of the GNU Lesser General Public License as published by the Free # 13 # Software Foundation, either version 3 of the License, or (at your option) # 14 # any later version. # 15 # # 16 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 18 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 19 # details. # 20 # # 21 # You should have received a copy of the GNU Lesser General Public License # 22 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 23 # # 24 ################################################################################ 25 26 from . import Framework 27 28 29 class Issue140(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issues/140 30 def setUp(self): 31 super().setUp() 32 self.repo = self.g.get_repo("twitter/bootstrap") 33 34 def testGetDirContentsThenLazyCompletionOfFile(self): 35 contents = self.repo.get_contents("js") 36 self.assertEqual(len(contents), 15) 37 n = 0 38 for content in contents: 39 if content.path == "js/bootstrap-affix.js": 40 self.assertEqual(len(content.content), 4722) # Lazy completion 41 n += 1 42 elif content.path == "js/tests": 43 self.assertEqual(content.content, None) # No completion at all 44 n += 1 45 self.assertEqual(n, 2) 46 47 def testGetFileContents(self): 48 contents = self.repo.get_contents("js/bootstrap-affix.js") 49 self.assertEqual(contents.encoding, "base64") 50 self.assertEqual( 51 contents.url, 52 "https://api.github.com/repos/twitter/bootstrap/contents/js/bootstrap-affix.js", 53 ) 54 self.assertEqual(len(contents.content), 4722) 55 56 def testGetDirContentsWithRef(self): 57 self.assertEqual( 58 len(self.repo.get_contents("js", "8c7f9c66a7d12f47f50618ef420868fe836d0c33")), 59 15, 60 )