From 66d0e35381ada75a8958847281d17682595f537d Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 10 Mar 2021 12:02:40 +0300 Subject: Run yapf-formatter against file --- 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 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" + }) -- cgit v1.2.3