Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_multiple_string_args(self):
url = endpoint.Endpoint.build_url('{}/{}', 'arg1', 'arg2')
path = urlsplit(url).path
self.assertEqual(path, '/arg1/arg2')
def test_multiple_string_args_used_in_order_given(self):
url = endpoint.Endpoint.build_url('{}/{}', 'arg2', 'arg1')
path = urlsplit(url).path
self.assertEqual(path, '/arg2/arg1')
def test_extra_args_arg_ignored(self):
url = endpoint.Endpoint.build_url('path', 1)
path = urlsplit(url).path
self.assertEqual(path, '/path')
def test_one_string_arg(self):
url = endpoint.Endpoint.build_url('{}', 'arg1')
path = urlsplit(url).path
self.assertEqual(path, '/arg1')
def test_token_included_as_param(self):
url = endpoint.Endpoint.build_url()
params = urlsplit(url).query
self.assertIn('token=TOKEN', params)
def test_literal_path(self):
url = endpoint.Endpoint.build_url('path')
path = urlsplit(url).path
self.assertEqual(path, '/path')
def test_nonstring_endpoint_url_raises_TypeError_with_path_and_args(self):
old = endpoint.Endpoint.url
endpoint.Endpoint.url = object()
with self.assertRaises(TypeError):
endpoint.Endpoint.build_url('path', 'arg')
endpoint.Endpoint.url = old
def test_nonstring_endpoint_url_raises_TypeError_with_path(self):
old = endpoint.Endpoint.url
endpoint.Endpoint.url = object()
with self.assertRaises(TypeError):
endpoint.Endpoint.build_url('path')
endpoint.Endpoint.url = old
def test_not_enough_args_raises_IndexError(self):
with self.assertRaises(IndexError):
endpoint.Endpoint.build_url('{}')