Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc5517c

Browse files
Merge pull requestsigmavirus24#611 from bluekeyes/refresh-json
Update JSON data in refresh()
2 parentsf6948ac +6290a69 commitdc5517c

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

‎AUTHORS.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,6 @@ Contributors
127127

128128
- Matthew Krueger (@mlkrueger1987)
129129

130-
- Dejan Svetec (@dsvetec)
130+
- Dejan Svetec (@dsvetec)
131+
132+
- Billy Keyes (@bluekeyes)

‎github3/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ def refresh(self, conditional=False):
285285
headers=headersorNone
286286
json=self._json(self._get(self._api,headers=headers),200)
287287
ifjsonisnotNone:
288+
self._json_data=json
288289
self._update_attributes(json)
289290
returnself
290291

‎tests/unit/test_models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importio
2+
importjson
23
importpytest
34
importrequests
45

@@ -184,6 +185,21 @@ def test_refresh_etag(self):
184185
headers=expected_headers,
185186
)
186187

188+
deftest_refresh_json(self):
189+
"""Verify refreshing an object updates stored json data."""
190+
expected_data= {
191+
'changed_files':4
192+
}
193+
response=requests.Response()
194+
response.status_code=200
195+
response.raw=io.BytesIO(json.dumps(expected_data).encode('utf8'))
196+
self.session.get.return_value=response
197+
198+
self.instance.refresh()
199+
200+
assert'changed_files'inself.instance.as_dict()
201+
assertself.instance.changed_files==4
202+
187203
deftest_strptime(self):
188204
"""Verify that method converts ISO 8601 formatted string."""
189205
dt=self.instance._strptime('2015-06-18T19:53:04Z')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp