Skip to content

Commit aa30d01

Browse files
committed
Differentiate rest_endpoint from new endpoint param #127
1 parent 09d0cb6 commit aa30d01

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

tests/test_basic.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def test_page_query(self):
338338
qstr = page._query('wikidata', qobj)
339339
self.assertTrue('action=wbgetentities' in qstr)
340340

341-
page.params.update({'endpoint': '/page/summary/'})
341+
page.params.update({'rest_endpoint': '/page/summary/'})
342342
qstr = page._query('restbase', qobj)
343343
self.assertTrue('api/rest' in qstr)
344344

@@ -552,7 +552,8 @@ def test_page_get_random(self):
552552
self.assertTrue('requests' not in page.data)
553553

554554
def test_page_get_restbase(self):
555-
page = wptools.page('TEST', endpoint='summary', silent=SILENT_FLAG)
555+
page = wptools.page('TEST', silent=SILENT_FLAG)
556+
page.params.update({'rest_endpoint': 'summary'})
556557
page.cache = {'restbase': rest_summary.cache}
557558
page._set_data('restbase')
558559
data = page.data
@@ -799,8 +800,7 @@ def test_restbase_init(self):
799800
self.assertTrue('requests' not in page.data)
800801

801802
def test_get_restbase_page(self):
802-
page = wptools.restbase(silent=SILENT_FLAG)
803-
page.params.update({'endpoint': '/page/'})
803+
page = wptools.restbase('/page/', silent=SILENT_FLAG)
804804
page.cache['restbase'] = rest_page.cache
805805
page._set_data('restbase')
806806
self.assertTrue('requests' not in page.data)
@@ -840,7 +840,7 @@ def test_get_restbase_lead(self):
840840

841841
def test_get_restbase_summary(self):
842842
page = wptools.restbase('TEST', silent=SILENT_FLAG)
843-
page.params.update({'endpoint': '/page/summary/'})
843+
page.params.update({'rest_endpoint': '/page/summary/'})
844844
page.cache['restbase'] = rest_summary.cache
845845
page._set_data('restbase')
846846

wptools/page.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ def _query(self, action, qobj):
157157
title = self.params.get('title')
158158
pageid = self.params.get('pageid')
159159
wikibase = self.params.get('wikibase')
160-
endpoint = self.params.get('endpoint')
161160

162161
qstr = None
163162

@@ -176,7 +175,7 @@ def _query(self, action, qobj):
176175
elif action == 'wikidata':
177176
qstr = qobj.wikidata(title, wikibase)
178177
elif action == 'restbase':
179-
qstr = qobj.restbase(endpoint, title)
178+
qstr = qobj.restbase(self.params.get('rest_endpoint'), title)
180179

181180
if qstr is None:
182181
raise ValueError("Unknown action: %s" % action)

wptools/restbase.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def _query(self, action, qobj):
6868
"""
6969
returns WPToolsQuery string from action
7070
"""
71-
return qobj.restbase(self.params['endpoint'], self.params.get('title'))
71+
return qobj.restbase(self.params['rest_endpoint'],
72+
self.params.get('title'))
7273

7374
def _set_data(self, action):
7475
"""
@@ -170,7 +171,6 @@ def get_restbase(self, endpoint='/page/',
170171
171172
Optional {params}:
172173
- [title]: <str> Mediawiki page title, file, category, etc.
173-
- [endpoint]: the RESTBase entry point (default=/page/)
174174
- [lang]: <str> Mediawiki language code (default=en)
175175
176176
Optional arguments:
@@ -195,7 +195,7 @@ def get_restbase(self, endpoint='/page/',
195195
if endpoint != '/page/' and not self.params.get('title'):
196196
raise StandardError("endpoint %s needs a title" % endpoint)
197197

198-
self.params.update({'endpoint': endpoint})
198+
self.params.update({'rest_endpoint': endpoint})
199199

200200
self._get('restbase', show, proxy, timeout)
201201

0 commit comments

Comments
 (0)