File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,12 @@ class PullFile(models.GitHubCore):
136
136
137
137
The patch generated by this
138
138
139
+ .. note::
140
+
141
+ If the patch is larger than a specific size it may be missing
142
+ from GitHub's response. The attribute will be set to ``None``
143
+ in this case.
144
+
139
145
.. attribute:: raw_url
140
146
141
147
The API resource to view the raw diff of this file
@@ -158,7 +164,7 @@ def _update_attributes(self, pfile):
158
164
self .changes_count = pfile ['changes' ]
159
165
self .blob_url = pfile ['blob_url' ]
160
166
self .raw_url = pfile ['raw_url' ]
161
- self .patch = pfile [ 'patch' ]
167
+ self .patch = pfile . get ( 'patch' )
162
168
self .contents_url = pfile ['contents_url' ]
163
169
164
170
def _repr (self ):
Original file line number Diff line number Diff line change
1
+ {
2
+ "sha": "bbcd538c8e72b8c175046e27cc8f907076331401",
3
+ "filename": "file1.txt",
4
+ "status": "added",
5
+ "additions": 103,
6
+ "deletions": 21,
7
+ "changes": 124,
8
+ "blob_url": "https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
9
+ "raw_url": "https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
10
+ "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e"
11
+ }
Original file line number Diff line number Diff line change @@ -286,3 +286,21 @@ def test_contents(self):
286
286
self .session .get .assert_called_once_with (
287
287
self .example_data ['contents_url' ]
288
288
)
289
+
290
+
291
+ class TestPullFilePatch (helper .UnitHelper ):
292
+ """Unit tests for the PullFile class with empty patch."""
293
+
294
+ described_class = pulls .PullFile
295
+ get_pull_file_patch_example_data = helper .create_example_data_helper (
296
+ 'pull_file_patch_example'
297
+ )
298
+ example_data = get_pull_file_patch_example_data ()
299
+
300
+ def test_contents (self ):
301
+ """Verify the request made to fetch a pull request file contents."""
302
+ self .instance .contents ()
303
+
304
+ self .session .get .assert_called_once_with (
305
+ self .example_data ['contents_url' ]
306
+ )
You can’t perform that action at this time.
0 commit comments