8000 ensure wp-api-v1 compat · boostsup/wp-api-python@1b20bd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b20bd1

Browse files
author
derwentx
committed
ensure wp-api-v1 compat
1 parent f82f514 commit 1b20bd1

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

tests.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,22 @@ def setUp(self):
10081008
})
10091009
self.wpapi = API(**self.api_params)
10101010

1011+
class WPAPITestCasesBasicV1(WPAPITestCasesBase):
1012+
def setUp(self):
1013+
super(WPAPITestCasesBasicV1, self).setUp()
1014+
self.api_params.update({
1015+
'user_auth': True,
1016+
'basic_auth': True,
1017+
'query_string_auth': False,
1018+
'version': 'wp/v1'
1019+
})
1020+
self.wpapi = API(**self.api_params)
1021+
1022+
def test_get_endpoint_url(self):
1023+
endpoint_url = self.wpapi.requester.endpoint_url('')
1024+
print endpoint_url
1025+
1026+
10111027
class WPAPITestCases3leg(WPAPITestCasesBase):
10121028
def setUp(self):
10131029
super(WPAPITestCases3leg, self).setUp()

wordpress/transport.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,23 @@ def is_ssl(self):
4040

4141
@property
4242
def api_url(self):
43-
return UrlUtils.join_components([
43+
components = [
4444
self.url,
4545
self.api
46-
])
46+
]
47+
return UrlUtils.join_components(components)
4748

4849
@property
4950
def api_ver_url(self):
50-
return UrlUtils.join_components([
51+
components = [
5152
self.url,
5253
self.api,
53-
self.api_version
54-
])
54+
]
55+
if self.api_version != 'wp/v1':
56+
components += [
57+
self.api_version
58+
]
59+
return UrlUtils.join_components(components)
5560

5661
@property
5762
def api_ver_url_no_port(self):
@@ -61,12 +66,18 @@ def endpoint_url(self, endpoint):
6166
endpoint = StrUtils.decapitate(endpoint, self.api_ver_url)
6267
endpoint = StrUtils.decapitate(endpoint, self.api_ver_url_no_port)
6368
endpoint = StrUtils.decapitate(endpoint, '/')
64-
return UrlUtils.join_components([
69+
components = [
6570
self.url,
66-
self.api,
67-
self.api_version,
71+
self.api
72+
]
73+
if self.api_version != 'wp/v1':
74+
components += [
75+
self.api_version
76+
]
77+
components += [
6878
endpoint
69-
])
79+
]
80+
return UrlUtils.join_components(components)
7081

7182
def request(self, method, url, auth=None, params=None, data=None, **kwargs):
7283
headers = {

0 commit comments

Comments
 (0)
0