8000 Ensure query string is included when building _api URL. Fixes #672 · pythonthings/github3.py@71508d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 71508d1

Browse files
committed
Ensure query string is included when building _api URL. Fixes sigmavirus24#672
1 parent 1edaca3 commit 71508d1

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

github3/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ def _build_url(self, *args, **kwargs):
276276

277277
@property
278278
def _api(self):
279-
return "{0.scheme}://{0.netloc}{0.path}".format(self._uri)
279+
value = "{0.scheme}://{0.netloc}{0.path}".format(self._uri)
280+
if self._uri.query:
281+
value += '?{}'.format(self._uri.query)
282+
return value
280283

281284
@_api.setter
282285
def _api(self, uri):

tests/unit/test_models.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,24 @@ def test_strptime(self):
216216
def test_strptime_time_str_required(self):
217217
"""Verify that method converts ISO 8601 formatted string."""
218218
assert self.instance._strptime('') is None
219+
220+
221+
class TestGitHubCoreIssue672(helper.UnitHelper):
222+
223+
described_class = MyTestRefreshClass
224+
last_modified = datetime.now().strftime(
225+
'%a, %d %b %Y %H:%M:%S GMT'
226+
)
227+
url = 'https://api.github.com/foo?bar=1'
228+
etag = '644b5b0155e6404a9cc4bd9d8b1ae730'
229+
example_data = {
230+
'url': url,
231+
'last_modified': last_modified,
232+
'etag': etag,
233+
'fake_attr': 'foo',
234+
}
235+
236+
def test_issue_672(self):
237+
"""Verify that _api property contains URL query"""
238+
assert '?' in self.instance._api
239+
assert self.instance._api == self.url

0 commit comments

Comments
 (0)
0