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_list_test(self):
l = [1, 2, 3, 4]
self.assertEqual(variable.list_test(l), True)
l = str([1, 2, 3, 4])
self.assertEqual(variable.list_test(l), False)
def test_list_of_tuples_test(self):
l = [(1, 2), (3, 4)]
self.assertEqual(variable.dict_test(l), False)
d = dict(l)
self.assertEqual(variable.dict_test(d), True)
def test_list_of_tuples_test(self):
l = [(1, 2), (3, 4)]
self.assertEqual(variable.dict_test(l), False)
d = dict(l)
self.assertEqual(variable.dict_test(d), True)
def test_list_test(self):
l = [1, 2, 3, 4]
self.assertEqual(variable.list_test(l), True)
l = str([1, 2, 3, 4])
self.assertEqual(variable.list_test(l), False)
def test_httpverb(self):
"""Test that each HTTP verb works properly when JSON is returned."""
verbs_to_methods = [
('GET', self.client.get),
('POST', self.client.post),
('PUT', self.client.put),
('PATCH', self.client.patch),
('DELETE', self.client.delete),
('HEAD', self.client.head),
('OPTIONS', self.client.options),
]
for verb, method in verbs_to_methods:
url = uritemplate.expand(self.client.url, {'param': 'foo'})
self.adapter.register_uri(verb, url, text='{"success": true}')
response = method(param='foo')
assert response.success
# test named param inference
response = method('foo')
assert response.success
def test_default_value(self):
uri = 'https://api.github.com/user{/user=sigmavirus24}'
t = URITemplate(uri)
self.assertEqual(t.expand(),
'https://api.github.com/user/sigmavirus24')
self.assertEqual(t.expand(user='lukasa'),
'https://api.github.com/user/lukasa')
def setUp(self):
self.v = variable.URIVariable('{foo}')
def test_post_parse_plus(self):
v = self.v
v.operator = '+'
v.post_parse()
self.assertEqual(v.join_str, ',')
self.assertEqual(v.safe, variable.URIVariable.reserved)
self.assertEqual(v.start, '')
def test_post_parse_octothorpe(self):
v = self.v
v.operator = '#'
v.post_parse()
self.assertEqual(v.join_str, ',')
self.assertEqual(v.safe, variable.URIVariable.reserved)
self.assertEqual(v.start, '#')
def test_is_list_of_tuples(self):
l = [(1, 2), (3, 4)]
self.assertEqual(variable.is_list_of_tuples(l), (True, l))
l = [1, 2, 3, 4]
self.assertEqual(variable.is_list_of_tuples(l), (False, None))