Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
description='y',
snippet='z',
user=self.factory.user,
org=self.factory.org
)
models.db.session.add(qs)
models.db.session.commit()
res = self.make_request(
'get',
'/api/query_snippets',
user=self.factory.user)
self.assertEqual(res.status_code, 200)
data = res.json
self.assertEqual(len(data), 1)
self.assertEqual(
project(data[0], ['id', 'trigger', 'description', 'snippet']), {
'id': 1,
'trigger': 'x',
'description': 'y',
'snippet': 'z',
})
self.assertEqual(qs.trigger, 'x')
self.assertEqual(qs.description, 'y')
self.assertEqual(qs.snippet, 'z')
def test_signup_missing_args(client, signup_email_request_data, missing_arg, error_msg):
response = client.post(
reverse('api:signup'),
funcy.omit(signup_email_request_data(), [missing_arg]),
content_type='application/json',
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.json() == error_msg
def test_fruit_create_missing_args(client, random_password, new_user, fruit_request_data, missing_arg, error_msg):
password = random_password()
user = new_user(password=password)
assert client.login(username=user.username, password=password)
response = client.post(
reverse('api:fruit-list'),
funcy.omit(fruit_request_data(), [missing_arg]),
content_type='application/json',
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.json() == error_msg
def test_lsplit():
assert lsplit(_ % 2, range(5)) == ([1, 3], [0, 2, 4])
# This behaviour moved to split_at()
with pytest.raises(TypeError): lsplit(2, range(5))
def filtergroups(gs):
return [project(g, g_keys) for g in gs]
self.assertEqual(filtergroups(response.json),
def test_pairwise():
assert list(pairwise(range(3))) == [(0, 1), (1, 2)]
def test_with_next():
assert list(with_next(range(3))) == [(0, 1), (1, 2), (2, None)]
def test_with_prev():
assert list(with_prev(range(3))) == [(0, None), (1, 0), (2, 1)]
def test_iterable():
assert iterable([])
assert iterable({})
assert iterable('abc')
assert iterable(iter([]))
assert iterable(x for x in range(10))
assert iterable(range(10))
assert not iterable(1)
def test_chunks():
assert lchunks(2, [0, 1, 2, 3, 4]) == [[0, 1], [2, 3], [4]]
assert lchunks(2, 1, [0, 1, 2, 3]) == [[0, 1], [1, 2], [2, 3], [3]]
assert lchunks(3, 1, iter(range(3))) == [[0, 1, 2], [1, 2], [2]]