Bugfix catch attribute errors and updated dependencies

This commit is contained in:
jfriedli 2022-01-24 19:43:12 +00:00
parent 8689aa3c31
commit 71b00c2098
7 changed files with 491 additions and 816 deletions

View file

@ -58,6 +58,14 @@ class Mat2WebTestCase(TestCase):
), follow_redirects=False)
self.assertEqual(rv.status_code, 302)
def test_get_upload_bad_file_type(self):
rv = self.client.post('/',
data=dict(
file=(io.BytesIO(b"1,2,3 \n 4,5,6"), 'test.csv'),
), follow_redirects=False)
self.assertEqual(rv.status_code, 200)
self.assertIn(b'The type text/csv could not be cleaned', rv.data)
def test_get_upload_empty_file_redir(self):
rv = self.client.post('/',
data=dict(

View file

@ -88,6 +88,18 @@ class Mat2APITestCase(unittest.TestCase):
error = request.get_json()['message']
self.assertEqual(error, 'The filetype is not supported')
def test_api_not_supported_extension(self):
request = self.app.post('/api/upload',
data='{"file_name": "test_name.csv", '
'"file": "MSwyLDMKNCw1LDY="}',
headers={'content-type': 'application/json'}
)
self.assertEqual(request.headers['Content-Type'], 'application/json')
self.assertEqual(request.status_code, 415)
error = request.get_json()['message']
self.assertEqual(error, 'The filetype is not supported')
def test_api_supported_extensions(self):
rv = self.app.get('/api/extension')
self.assertEqual(rv.status_code, 200)
@ -478,6 +490,20 @@ class Mat2APITestCase(unittest.TestCase):
self.assertEqual(r.headers['Content-Type'], 'text/plain; charset=utf-8')
self.assertEqual(r.data, b'')
def test_remove_metadata_not_supported_extension(self):
r = self.app.post(
'/api/remove_metadata',
data=dict(
file=(io.BytesIO(b"1,2,3 \n 4,5,6"), 'test.csv'),
),
follow_redirects=False
)
self.assertEqual(
r.get_json()['message'],
'The filetype is not supported'
)
self.assertEqual(r.status_code, 415)
def test_remove_metdata_validation(self):
r = self.app.post(
'/api/remove_metadata',