From 4a1907207bbf44474b689d1f4ffaa4055948bb2c Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 11 May 2024 08:01:07 +0000 Subject: [PATCH] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in e2962d6 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- tests/test_api.py | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 36014fb..867f0db 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,17 +1,19 @@ # API test file import os -import tempfile import shutil +import tempfile import unittest + from app import app, db -from app.models import User, File +from app.models import File, User from app.services.encryption import encrypt_file + class TestAPI(unittest.TestCase): def setUp(self): - app.config['TESTING'] = True - app.config['WTF_CSRF_ENABLED'] = False - app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' + app.config["TESTING"] = True + app.config["WTF_CSRF_ENABLED"] = False + app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://" self.client = app.test_client() db.create_all() @@ -21,34 +23,37 @@ def tearDown(self): def test_upload_file(self): with tempfile.TemporaryDirectory() as temp_dir: - file_path = os.path.join(temp_dir, 'test_file.txt') - with open(file_path, 'w') as f: - f.write('Test file content') - with open(file_path, 'rb') as f: + file_path = os.path.join(temp_dir, "test_file.txt") + with open(file_path, "w") as f: + f.write("Test file content") + with open(file_path, "rb") as f: file = f.read() encrypted_file = encrypt_file(file) - response = self.client.post('/files', data={ - 'username': 'test_user', - 'file': (file_path, 'test_file.txt') - }) + response = self.client.post( + "/files", + data={"username": "test_user", "file": (file_path, "test_file.txt")}, + ) self.assertEqual(response.status_code, 200) self.assertTrue(File.query.count() > 0) def test_download_file(self): with tempfile.TemporaryDirectory() as temp_dir: - file_path = os.path.join(temp_dir, 'test_file.txt') - with open(file_path, 'w') as f: - f.write('Test file content') - with open(file_path, 'rb') as f: + file_path = os.path.join(temp_dir, "test_file.txt") + with open(file_path, "w") as f: + f.write("Test file content") + with open(file_path, "rb") as f: file = f.read() encrypted_file = encrypt_file(file) ipfs_hash = IPFS.add(encrypted_file) - file = File(name='test_file.txt', content=ipfs_hash, user=User(username='test_user')) + file = File( + name="test_file.txt", content=ipfs_hash, user=User(username="test_user") + ) db.session.add(file) db.session.commit() - response = self.client.get(f'/files/{ipfs_hash}') + response = self.client.get(f"/files/{ipfs_hash}") self.assertEqual(response.status_code, 200) self.assertTrue(response.content) -if __name__ == '__main__': + +if __name__ == "__main__": unittest.main()