From 4dfb9d5d06d3544aea5c769b71537f51234ae74c Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 19 Mar 2021 16:36:01 +0300 Subject: Apply autopep-8 --- tests/unit/test_file_utils.py | 34 +++++++++++++++------------------- 1 file 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" + }) -- cgit v1.2.3