aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/unit/test_file_utils.py34
1 files changed, 15 insertions, 19 deletions
diff --git a/tests/unit/test_file_utils.py b/tests/unit/test_file_utils.py
index af86ba8..bd54a6a 100644
--- a/tests/unit/test_file_utils.py
+++ b/tests/unit/test_file_utils.py
@@ -27,22 +27,20 @@ class TestFileUtils(unittest.TestCase):
def test_get_dir_hash_non_existent_dir(self):
"""Test thata an error is raised when the dir does not exist"""
- self.assertRaises(FileNotFoundError,
- get_dir_hash,
+ self.assertRaises(FileNotFoundError, get_dir_hash,
"/non-existent-file")
def test_jsonfile_to_dict(self):
- """Test that a json file is parsed correctly"""""
- json_file = os.path.join(os.path.dirname(__file__),
- "test_data", "metadata.json")
+ """Test that a json file is parsed correctly""" ""
+ json_file = os.path.join(os.path.dirname(__file__), "test_data",
+ "metadata.json")
self.assertEqual("Longer description",
jsonfile_to_dict(json_file).get("description"))
def test_jsonfile_to_dict_nonexistent_file(self):
"""Test that a ValueError is raised when the json file is
non-existent"""
- self.assertRaises(FileNotFoundError,
- jsonfile_to_dict,
+ self.assertRaises(FileNotFoundError, jsonfile_to_dict,
"/non-existent-dir")
@mock.patch("gn3.file_utils.tarfile")
@@ -53,25 +51,23 @@ non-existent"""
mock_fileobj = MockFile(save=mock.MagicMock(),
filename="upload-data.tar.gz")
mock_tarfile.return_value = mock.Mock()
- result = extract_uploaded_file(mock_fileobj, "/tmp",
+ result = extract_uploaded_file(mock_fileobj,
+ "/tmp",
token="abcdef-abcdef")
mock_fileobj.save.assert_called_once_with("/tmp/abcdef-abcdef/"
"upload-data.tar.gz")
mock_file.assert_called_once_with("upload-data.tar.gz")
- self.assertEqual(result,
- {"status": 0,
- "token": "abcdef-abcdef"})
+ self.assertEqual(result, {"status": 0, "token": "abcdef-abcdef"})
@mock.patch("gn3.file_utils.secure_filename")
def test_extract_uploaded_file_non_existent_gzip(self, mock_file):
"""Test that the right error message is returned when there is a problem
extracting the file"""
- mock_file.return_value = os.path.join(
- os.path.dirname(__file__),
- "CTtyodSTh5") # Does not exist!
- mock_fileobj = MockFile(save=mock.MagicMock(),
- filename="")
+ mock_file.return_value = os.path.join(os.path.dirname(__file__),
+ "CTtyodSTh5") # Does not exist!
+ mock_fileobj = MockFile(save=mock.MagicMock(), filename="")
result = extract_uploaded_file(mock_fileobj, "/tmp")
- self.assertEqual(result,
- {"status": 128,
- "error": "gzip failed to unpack file"})
+ self.assertEqual(result, {
+ "status": 128,
+ "error": "gzip failed to unpack file"
+ })