예제 #1
0
 def test_url_join_components(self):
     self.assertEqual(
         'https://woo.test:8888/wp-json',
         UrlUtils.join_components(['https://woo.test:8888/', '', 'wp-json'])
     )
     self.assertEqual(
         'https://woo.test:8888/wp-json/wp/v2',
         UrlUtils.join_components(['https://woo.test:8888/', 'wp-json', 'wp/v2'])
     )
예제 #2
0
 def api_ver_url(self):
     components = [
         self.url,
         self.api,
     ]
     if self.api_version != 'wp/v1':
         components += [self.api_version]
     return UrlUtils.join_components(components)
예제 #3
0
 def test_endpoint_url(self):
     api = API(**self.api_params)
     endpoint_url = api.requester.endpoint_url(self.endpoint)
     endpoint_url = api.auth.get_auth_url(endpoint_url, 'GET')
     self.assertEqual(
         endpoint_url,
         UrlUtils.join_components(
             [self.base_url, self.api_name, self.api_ver, self.endpoint]))
예제 #4
0
 def api_ver_url(self):
     components = [
         self.url,
         self.api,
     ]
     if not self.is_wp_json_v1:
         components += [self.api_version]
     return UrlUtils.join_components(components)
예제 #5
0
 def endpoint_url(self, endpoint):
     endpoint = StrUtils.decapitate(endpoint, self.api_ver_url)
     endpoint = StrUtils.decapitate(endpoint, self.api_ver_url_no_port)
     endpoint = StrUtils.decapitate(endpoint, '/')
     components = [self.url, self.api]
     if self.api_version != 'wp/v1':
         components += [self.api_version]
     components += [endpoint]
     return UrlUtils.join_components(components)
예제 #6
0
 def test_query_string_endpoint_url(self):
     query_string_api_params = dict(**self.api_params)
     query_string_api_params.update(dict(query_string_auth=True))
     api = API(**query_string_api_params)
     endpoint_url = api.requester.endpoint_url(self.endpoint)
     endpoint_url = api.auth.get_auth_url(endpoint_url, 'GET')
     expected_endpoint_url = '%s?consumer_key=%s&consumer_secret=%s' % (
         self.endpoint, self.consumer_key, self.consumer_secret)
     expected_endpoint_url = UrlUtils.join_components([
         self.base_url, self.api_name, self.api_ver, expected_endpoint_url
     ])
     self.assertEqual(endpoint_url, expected_endpoint_url)
     endpoint_url = api.requester.endpoint_url(self.endpoint)
     endpoint_url = api.auth.get_auth_url(endpoint_url, 'GET')
예제 #7
0
 def api_url(self):
     components = [self.url, self.api]
     return UrlUtils.join_components(components)
예제 #8
0
 def endpoint_url(self, endpoint):
     endpoint = StrUtils.decapitate(endpoint, '/')
     return UrlUtils.join_components(
         [self.url, self.api, self.api_version, endpoint])
예제 #9
0
 def api_url(self):
     return UrlUtils.join_components([self.url, self.api])