PullRequestFile.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 . import Framework 30 31 32 class PullRequestFile(Framework.TestCase): 33 def setUp(self): 34 super().setUp() 35 self.file = self.g.get_user().get_repo("PyGithub").get_pull(31).get_files()[0] 36 37 def testAttributes(self): 38 self.assertEqual(self.file.additions, 1) 39 self.assertEqual( 40 self.file.blob_url, 41 "https://github.com/jacquev6/PyGithub/blob/8a4f306d4b223682dd19410d4a9150636ebe4206/codegen/templates/GithubObject.py", 42 ) 43 self.assertEqual(self.file.changes, 2) 44 self.assertEqual(self.file.deletions, 1) 45 self.assertEqual(self.file.filename, "codegen/templates/GithubObject.py") 46 self.assertEqual( 47 self.file.patch, 48 '@@ -70,7 +70,7 @@ def __useAttributes( self, attributes ):\n \n # @toto No need to check if attribute is in attributes when attribute is mandatory\n {% for attribute in class.attributes|dictsort:"name" %}\n- if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None:\n+ if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None: # pragma no branch\n \n {% if attribute.type.cardinality == "scalar" %}\n {% if attribute.type.simple %}', 49 ) 50 self.assertEqual( 51 self.file.raw_url, 52 "https://github.com/jacquev6/PyGithub/raw/8a4f306d4b223682dd19410d4a9150636ebe4206/codegen/templates/GithubObject.py", 53 ) 54 self.assertEqual(self.file.sha, "8a4f306d4b223682dd19410d4a9150636ebe4206") 55 self.assertEqual(self.file.status, "modified") 56 self.assertEqual( 57 repr(self.file), 58 'File(sha="8a4f306d4b223682dd19410d4a9150636ebe4206", filename="codegen/templates/GithubObject.py")', 59 )