diff options
author | BonfaceKilz | 2021-03-19 16:36:01 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-03-23 01:14:37 +0300 |
commit | 4dfb9d5d06d3544aea5c769b71537f51234ae74c (patch) | |
tree | aa458716d47717e8c2ebcf568f41268c6cd64699 /tests/unit | |
parent | ca53d3ba5177555fae95d49ced399dc1ad4fd442 (diff) | |
download | genenetwork3-4dfb9d5d06d3544aea5c769b71537f51234ae74c.tar.gz |
Apply autopep-8
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/test_file_utils.py | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/tests/unit/test_file_utils.py b/tests/unit/test_file_utils.py index a0f83ee..b319693 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,7 +51,8 @@ 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") @@ -62,20 +61,17 @@ non-existent""" mock_tarfile.open.return_value.extractall.assert_called_once_with( path='/tmp/abcdef-abcdef') 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" + }) |