summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorjfriedli2022-01-24 19:43:12 +0000
committerjfriedli2022-01-24 19:43:12 +0000
commit71b00c20981eccf92ab7af0dc311543f077e327f (patch)
tree6094c2c110395743165853a4706bb0139be9c1b0 /test
parent8689aa3c3144dbe6a7b67facd176cf0d7dbf8cc6 (diff)
Bugfix catch attribute errors and updated dependencies
Diffstat (limited to 'test')
-rw-r--r--test/test.py8
-rw-r--r--test/test_api.py26
2 files changed, 34 insertions, 0 deletions
diff --git a/test/test.py b/test/test.py
index d9d0fbf..4d2907f 100644
--- a/test/test.py
+++ b/test/test.py
@@ -58,6 +58,14 @@ class Mat2WebTestCase(TestCase):
58 ), follow_redirects=False) 58 ), follow_redirects=False)
59 self.assertEqual(rv.status_code, 302) 59 self.assertEqual(rv.status_code, 302)
60 60
61 def test_get_upload_bad_file_type(self):
62 rv = self.client.post('/',
63 data=dict(
64 file=(io.BytesIO(b"1,2,3 \n 4,5,6"), 'test.csv'),
65 ), follow_redirects=False)
66 self.assertEqual(rv.status_code, 200)
67 self.assertIn(b'The type text/csv could not be cleaned', rv.data)
68
61 def test_get_upload_empty_file_redir(self): 69 def test_get_upload_empty_file_redir(self):
62 rv = self.client.post('/', 70 rv = self.client.post('/',
63 data=dict( 71 data=dict(
diff --git a/test/test_api.py b/test/test_api.py
index 91ea043..181fe4b 100644
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -88,6 +88,18 @@ class Mat2APITestCase(unittest.TestCase):
88 error = request.get_json()['message'] 88 error = request.get_json()['message']
89 self.assertEqual(error, 'The filetype is not supported') 89 self.assertEqual(error, 'The filetype is not supported')
90 90
91 def test_api_not_supported_extension(self):
92 request = self.app.post('/api/upload',
93 data='{"file_name": "test_name.csv", '
94 '"file": "MSwyLDMKNCw1LDY="}',
95 headers={'content-type': 'application/json'}
96 )
97 self.assertEqual(request.headers['Content-Type'], 'application/json')
98 self.assertEqual(request.status_code, 415)
99
100 error = request.get_json()['message']
101 self.assertEqual(error, 'The filetype is not supported')
102
91 def test_api_supported_extensions(self): 103 def test_api_supported_extensions(self):
92 rv = self.app.get('/api/extension') 104 rv = self.app.get('/api/extension')
93 self.assertEqual(rv.status_code, 200) 105 self.assertEqual(rv.status_code, 200)
@@ -478,6 +490,20 @@ class Mat2APITestCase(unittest.TestCase):
478 self.assertEqual(r.headers['Content-Type'], 'text/plain; charset=utf-8') 490 self.assertEqual(r.headers['Content-Type'], 'text/plain; charset=utf-8')
479 self.assertEqual(r.data, b'') 491 self.assertEqual(r.data, b'')
480 492
493 def test_remove_metadata_not_supported_extension(self):
494 r = self.app.post(
495 '/api/remove_metadata',
496 data=dict(
497 file=(io.BytesIO(b"1,2,3 \n 4,5,6"), 'test.csv'),
498 ),
499 follow_redirects=False
500 )
501 self.assertEqual(
502 r.get_json()['message'],
503 'The filetype is not supported'
504 )
505 self.assertEqual(r.status_code, 415)
506
481 def test_remove_metdata_validation(self): 507 def test_remove_metdata_validation(self):
482 r = self.app.post( 508 r = self.app.post(
483 '/api/remove_metadata', 509 '/api/remove_metadata',