API - test refacto (response errors assertion)
This commit is contained in:
@ -49,10 +49,7 @@ class TestGetConfig(ApiTestCaseMixin):
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert 'error on getting configuration' in data['message']
|
||||
self.assert_500(response, 'error on getting configuration')
|
||||
|
||||
def test_it_returns_error_if_application_has_several_config(
|
||||
self, app: Flask, app_config: Flask, user_1_admin: User
|
||||
@ -67,10 +64,7 @@ class TestGetConfig(ApiTestCaseMixin):
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert 'error on getting configuration' in data['message']
|
||||
self.assert_500(response, 'error on getting configuration')
|
||||
|
||||
|
||||
class TestUpdateConfig(ApiTestCaseMixin):
|
||||
@ -140,11 +134,7 @@ class TestUpdateConfig(ApiTestCaseMixin):
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 403
|
||||
assert 'success' not in data['status']
|
||||
assert 'error' in data['status']
|
||||
assert 'you do not have permissions' in data['message']
|
||||
self.assert_403(response)
|
||||
|
||||
def test_it_returns_400_if_invalid_is_payload(
|
||||
self, app: Flask, user_1_admin: User
|
||||
@ -160,10 +150,7 @@ class TestUpdateConfig(ApiTestCaseMixin):
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert 'error' in data['status']
|
||||
assert 'invalid payload' in data['message']
|
||||
self.assert_400(response)
|
||||
|
||||
def test_it_returns_error_on_update_if_application_has_no_config(
|
||||
self, app_no_config: Flask, user_1_admin: User
|
||||
@ -179,10 +166,7 @@ class TestUpdateConfig(ApiTestCaseMixin):
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert 'error when updating configuration' in data['message']
|
||||
self.assert_500(response, 'error when updating configuration')
|
||||
|
||||
def test_it_raises_error_if_archive_max_size_is_below_files_max_size(
|
||||
self, app: Flask, user_1_admin: User
|
||||
@ -205,13 +189,13 @@ class TestUpdateConfig(ApiTestCaseMixin):
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Max. size of zip archive must be equal or greater than max. size '
|
||||
'of uploaded files'
|
||||
) in data['message']
|
||||
self.assert_400(
|
||||
response,
|
||||
(
|
||||
'Max. size of zip archive must be equal or greater than max.'
|
||||
' size of uploaded files'
|
||||
),
|
||||
)
|
||||
|
||||
def test_it_raises_error_if_archive_max_size_equals_0(
|
||||
self, app_with_max_file_size_equals_0: Flask, user_1_admin: User
|
||||
@ -231,12 +215,8 @@ class TestUpdateConfig(ApiTestCaseMixin):
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Max. size of zip archive must be greater than 0'
|
||||
in data['message']
|
||||
self.assert_400(
|
||||
response, 'Max. size of zip archive must be greater than 0'
|
||||
)
|
||||
|
||||
def test_it_raises_error_if_files_max_size_equals_0(
|
||||
@ -257,12 +237,8 @@ class TestUpdateConfig(ApiTestCaseMixin):
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Max. size of uploaded files must be greater than 0'
|
||||
in data['message']
|
||||
self.assert_400(
|
||||
response, 'Max. size of uploaded files must be greater than 0'
|
||||
)
|
||||
|
||||
def test_it_raises_error_if_gpx_limit_import_equals_0(
|
||||
@ -283,10 +259,6 @@ class TestUpdateConfig(ApiTestCaseMixin):
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Max. files in a zip archive must be greater than 0'
|
||||
in data['message']
|
||||
self.assert_400(
|
||||
response, 'Max. files in a zip archive must be greater than 0'
|
||||
)
|
||||
|
Reference in New Issue
Block a user