diff options
author | BonfaceKilz | 2021-03-10 12:51:36 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-03-10 12:53:12 +0300 |
commit | e6c8d3f3a43621ccc34f77b50e220eb684617146 (patch) | |
tree | f9f8b00748c578185592e3967b2f9b3d2ee56459 /tests/unit | |
parent | d31ccc82aa84432c6cfef1a0a2d8f34beee179cd (diff) | |
download | genenetwork3-e6c8d3f3a43621ccc34f77b50e220eb684617146.tar.gz |
Apply yapf file formatting to file
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/test_file_utils.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/tests/unit/test_file_utils.py b/tests/unit/test_file_utils.py index b319693..a0f83ee 100644 --- a/tests/unit/test_file_utils.py +++ b/tests/unit/test_file_utils.py @@ -27,20 +27,22 @@ 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") @@ -51,8 +53,7 @@ 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") @@ -61,17 +62,20 @@ 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"}) |