From 9f4606c3c4adbe26bb64132121cd80ddfd8ddaa2 Mon Sep 17 00:00:00 2001 From: Bence Csik <22349790+csikb@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:09:27 +0000 Subject: [PATCH] Remove packages (#66) ## Summary by CodeRabbit - **Refactor** - Updated import paths across multiple test files for better project structure organization. - **Tests** - Adjusted test cases to reflect updated import paths ensuring continued test reliability. --- poetry.lock | 2 +- pyproject.toml | 8 ++++---- src/{bss_web_file_server => }/__init__.py | 0 src/{bss_web_file_server => }/main.py | 0 .../models/__init__.py | 0 src/{bss_web_file_server => }/models/member.py | 0 src/{bss_web_file_server => }/models/video.py | 0 .../routers/__init__.py | 0 src/{bss_web_file_server => }/routers/health.py | 0 src/{bss_web_file_server => }/routers/member.py | 0 src/{bss_web_file_server => }/routers/video.py | 0 .../services/__init__.py | 0 src/{bss_web_file_server => }/services/image.py | 0 .../services/member.py | 0 src/{bss_web_file_server => }/services/video.py | 0 src/{bss_web_file_server => }/settings.py | 0 tests/bss_web_file_server/services/__init__.py | 0 .../{bss_web_file_server => models}/__init__.py | 0 .../models/test_member.py | 2 +- .../models/test_video.py | 2 +- .../models => routers}/__init__.py | 0 .../routers/test_health.py | 2 +- .../routers/test_member.py | 16 ++++++++-------- .../routers/test_video.py | 16 ++++++++-------- .../routers => services}/__init__.py | 0 .../services/mountains.jpg | Bin .../services/test_image.py | 2 +- .../services/test_member.py | 8 +++----- .../services/test_video.py | 8 +++----- tests/{bss_web_file_server => }/test_main.py | 10 +++++----- 30 files changed, 36 insertions(+), 40 deletions(-) rename src/{bss_web_file_server => }/__init__.py (100%) rename src/{bss_web_file_server => }/main.py (100%) rename src/{bss_web_file_server => }/models/__init__.py (100%) rename src/{bss_web_file_server => }/models/member.py (100%) rename src/{bss_web_file_server => }/models/video.py (100%) rename src/{bss_web_file_server => }/routers/__init__.py (100%) rename src/{bss_web_file_server => }/routers/health.py (100%) rename src/{bss_web_file_server => }/routers/member.py (100%) rename src/{bss_web_file_server => }/routers/video.py (100%) rename src/{bss_web_file_server => }/services/__init__.py (100%) rename src/{bss_web_file_server => }/services/image.py (100%) rename src/{bss_web_file_server => }/services/member.py (100%) rename src/{bss_web_file_server => }/services/video.py (100%) rename src/{bss_web_file_server => }/settings.py (100%) delete mode 100644 tests/bss_web_file_server/services/__init__.py rename tests/{bss_web_file_server => models}/__init__.py (100%) rename tests/{bss_web_file_server => }/models/test_member.py (79%) rename tests/{bss_web_file_server => }/models/test_video.py (93%) rename tests/{bss_web_file_server/models => routers}/__init__.py (100%) rename tests/{bss_web_file_server => }/routers/test_health.py (89%) rename tests/{bss_web_file_server => }/routers/test_member.py (84%) rename tests/{bss_web_file_server => }/routers/test_video.py (84%) rename tests/{bss_web_file_server/routers => services}/__init__.py (100%) rename tests/{bss_web_file_server => }/services/mountains.jpg (100%) rename tests/{bss_web_file_server => }/services/test_image.py (91%) rename tests/{bss_web_file_server => }/services/test_member.py (91%) rename tests/{bss_web_file_server => }/services/test_video.py (91%) rename tests/{bss_web_file_server => }/test_main.py (53%) diff --git a/poetry.lock b/poetry.lock index a0d3297..cd37228 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1638,4 +1638,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "e1611500d39412c65565c57b9ba14477dd6a49c789dbb301df86270bec2fa0b0" +content-hash = "0c958030e21f351715bbe5f6af19c4a4e89c86b9516012bfdf0e3639d8181cf0" diff --git a/pyproject.toml b/pyproject.toml index 635c53d..5c82312 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,9 @@ [tool.poetry] name = "bss-web-file-server" -version = "0.1.0" description = "BSS file server API" authors = ["Bence Csik "] readme = "README.md" -packages = [{include = "bss_web_file_server", from = "src"}] +package-mode = false [tool.poetry.dependencies] python = "^3.12" @@ -12,21 +11,22 @@ fastapi = {version="0.110.0", extras=["all"]} uvicorn = {version = "0.29.0", extras = ["standard"]} pillow = "10.2.0" pillow-avif-plugin = "1.4.3" +# used for UploadFile python-multipart = "0.0.9" [tool.poetry.group.dev.dependencies] +black = "24.3.0" pre-commit = "3.6.2" pylint = "3.1.0" -black = "24.3.0" isort = "5.13.2" types-Pillow = "10.2.0.20240311" +mypy = "1.9.0" [tool.poetry.group.test.dependencies] httpx = "^0.23.0" pytest = "^8.0.0" pytest-mock = "^3.10.0" pytest-cov = "^4.1.0" -mypy = "1.9.0" [tool.isort] profile = "black" diff --git a/src/bss_web_file_server/__init__.py b/src/__init__.py similarity index 100% rename from src/bss_web_file_server/__init__.py rename to src/__init__.py diff --git a/src/bss_web_file_server/main.py b/src/main.py similarity index 100% rename from src/bss_web_file_server/main.py rename to src/main.py diff --git a/src/bss_web_file_server/models/__init__.py b/src/models/__init__.py similarity index 100% rename from src/bss_web_file_server/models/__init__.py rename to src/models/__init__.py diff --git a/src/bss_web_file_server/models/member.py b/src/models/member.py similarity index 100% rename from src/bss_web_file_server/models/member.py rename to src/models/member.py diff --git a/src/bss_web_file_server/models/video.py b/src/models/video.py similarity index 100% rename from src/bss_web_file_server/models/video.py rename to src/models/video.py diff --git a/src/bss_web_file_server/routers/__init__.py b/src/routers/__init__.py similarity index 100% rename from src/bss_web_file_server/routers/__init__.py rename to src/routers/__init__.py diff --git a/src/bss_web_file_server/routers/health.py b/src/routers/health.py similarity index 100% rename from src/bss_web_file_server/routers/health.py rename to src/routers/health.py diff --git a/src/bss_web_file_server/routers/member.py b/src/routers/member.py similarity index 100% rename from src/bss_web_file_server/routers/member.py rename to src/routers/member.py diff --git a/src/bss_web_file_server/routers/video.py b/src/routers/video.py similarity index 100% rename from src/bss_web_file_server/routers/video.py rename to src/routers/video.py diff --git a/src/bss_web_file_server/services/__init__.py b/src/services/__init__.py similarity index 100% rename from src/bss_web_file_server/services/__init__.py rename to src/services/__init__.py diff --git a/src/bss_web_file_server/services/image.py b/src/services/image.py similarity index 100% rename from src/bss_web_file_server/services/image.py rename to src/services/image.py diff --git a/src/bss_web_file_server/services/member.py b/src/services/member.py similarity index 100% rename from src/bss_web_file_server/services/member.py rename to src/services/member.py diff --git a/src/bss_web_file_server/services/video.py b/src/services/video.py similarity index 100% rename from src/bss_web_file_server/services/video.py rename to src/services/video.py diff --git a/src/bss_web_file_server/settings.py b/src/settings.py similarity index 100% rename from src/bss_web_file_server/settings.py rename to src/settings.py diff --git a/tests/bss_web_file_server/services/__init__.py b/tests/bss_web_file_server/services/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/bss_web_file_server/__init__.py b/tests/models/__init__.py similarity index 100% rename from tests/bss_web_file_server/__init__.py rename to tests/models/__init__.py diff --git a/tests/bss_web_file_server/models/test_member.py b/tests/models/test_member.py similarity index 79% rename from tests/bss_web_file_server/models/test_member.py rename to tests/models/test_member.py index ca30342..c2999a1 100644 --- a/tests/bss_web_file_server/models/test_member.py +++ b/tests/models/test_member.py @@ -1,6 +1,6 @@ from uuid import UUID -from src.bss_web_file_server.models.member import Member +from src.models.member import Member def test_should_create_member(): diff --git a/tests/bss_web_file_server/models/test_video.py b/tests/models/test_video.py similarity index 93% rename from tests/bss_web_file_server/models/test_video.py rename to tests/models/test_video.py index e9d7a6a..a20a225 100644 --- a/tests/bss_web_file_server/models/test_video.py +++ b/tests/models/test_video.py @@ -3,7 +3,7 @@ import pytest from pydantic import ValidationError -from bss_web_file_server.models.video import Video +from src.models.video import Video valid_uid = UUID("{12345678-1234-5678-1234-567812345678}") valid_urls = ["url1", "url2"] diff --git a/tests/bss_web_file_server/models/__init__.py b/tests/routers/__init__.py similarity index 100% rename from tests/bss_web_file_server/models/__init__.py rename to tests/routers/__init__.py diff --git a/tests/bss_web_file_server/routers/test_health.py b/tests/routers/test_health.py similarity index 89% rename from tests/bss_web_file_server/routers/test_health.py rename to tests/routers/test_health.py index e250315..a4377c4 100644 --- a/tests/bss_web_file_server/routers/test_health.py +++ b/tests/routers/test_health.py @@ -1,7 +1,7 @@ from fastapi import FastAPI from fastapi.testclient import TestClient -from bss_web_file_server.routers import health +from src.routers import health app = FastAPI() app.include_router(health.router) diff --git a/tests/bss_web_file_server/routers/test_member.py b/tests/routers/test_member.py similarity index 84% rename from tests/bss_web_file_server/routers/test_member.py rename to tests/routers/test_member.py index 38fbbdc..039b12b 100644 --- a/tests/bss_web_file_server/routers/test_member.py +++ b/tests/routers/test_member.py @@ -2,8 +2,8 @@ from fastapi import FastAPI from fastapi.testclient import TestClient -from bss_web_file_server.models.member import Member -from bss_web_file_server.routers import member +from src.models.member import Member +from src.routers import member @pytest.fixture @@ -17,7 +17,7 @@ def client(): def test_create_member_folder(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.member.service") + service_mock = mocker.patch("src.routers.member.service") service_mock.create_folder_structure.return_value = None member_data = {"id": str(member_object.id), "url": member_object.url} @@ -31,7 +31,7 @@ def test_create_member_folder(client, mocker): def test_update_member_folder_no_id(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.member.service") + service_mock = mocker.patch("src.routers.member.service") service_mock.to_id_path.return_value.exists.return_value = False member_data = {"id": str(member_object.id), "url": member_object.url} @@ -43,7 +43,7 @@ def test_update_member_folder_no_id(client, mocker): def test_update_member_folder(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.member.service") + service_mock = mocker.patch("src.routers.member.service") service_mock.to_id_path.return_value.exists.return_value = True service_mock.update_symlink.return_value = None @@ -58,7 +58,7 @@ def test_update_member_folder(client, mocker): def test_upload_member_picture_no_id(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.member.service") + service_mock = mocker.patch("src.routers.member.service") service_mock.to_id_path.return_value.exists.return_value = False response = client.post( @@ -71,7 +71,7 @@ def test_upload_member_picture_no_id(client, mocker): def test_upload_member_picture_not_image(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.member.service") + service_mock = mocker.patch("src.routers.member.service") service_mock.to_id_path.return_value.exists.return_value = True response = client.post( @@ -85,7 +85,7 @@ def test_upload_member_picture_not_image(client, mocker): def test_upload_member_picture(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.member.service") + service_mock = mocker.patch("src.routers.member.service") service_mock.to_id_path.return_value.exists.return_value = True service_mock.create_profile_picture.return_value = None diff --git a/tests/bss_web_file_server/routers/test_video.py b/tests/routers/test_video.py similarity index 84% rename from tests/bss_web_file_server/routers/test_video.py rename to tests/routers/test_video.py index b8566ef..54c47a1 100644 --- a/tests/bss_web_file_server/routers/test_video.py +++ b/tests/routers/test_video.py @@ -2,8 +2,8 @@ from fastapi import FastAPI from fastapi.testclient import TestClient -from bss_web_file_server.models.video import Video -from bss_web_file_server.routers import video +from src.models.video import Video +from src.routers import video @pytest.fixture @@ -19,7 +19,7 @@ def client(): def test_create_video_folder(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.video.service") + service_mock = mocker.patch("src.routers.video.service") service_mock.create_folder_structure.return_value = None video_data = {"id": str(video_object.id), "urls": video_object.urls} @@ -33,7 +33,7 @@ def test_create_video_folder(client, mocker): def test_update_video_folder_no_id(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.video.service") + service_mock = mocker.patch("src.routers.video.service") service_mock.to_id_path.return_value.exists.return_value = False video_data = {"id": str(video_object.id), "urls": video_object.urls} @@ -45,7 +45,7 @@ def test_update_video_folder_no_id(client, mocker): def test_update_video_folder(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.video.service") + service_mock = mocker.patch("src.routers.video.service") service_mock.to_id_path.return_value.exists.return_value = True service_mock.update_symlinks.return_value = None @@ -60,7 +60,7 @@ def test_update_video_folder(client, mocker): def test_upload_video_poster_no_id(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.video.service") + service_mock = mocker.patch("src.routers.video.service") service_mock.to_id_path.return_value.exists.return_value = False response = client.post( @@ -73,7 +73,7 @@ def test_upload_video_poster_no_id(client, mocker): def test_upload_video_poster_not_image(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.video.service") + service_mock = mocker.patch("src.routers.video.service") service_mock.to_id_path.return_value.exists.return_value = True response = client.post( @@ -87,7 +87,7 @@ def test_upload_video_poster_not_image(client, mocker): def test_upload_video_poster(client, mocker): - service_mock = mocker.patch("bss_web_file_server.routers.video.service") + service_mock = mocker.patch("src.routers.video.service") service_mock.to_id_path.return_value.exists.return_value = True service_mock.create_thumbnails.return_value = None diff --git a/tests/bss_web_file_server/routers/__init__.py b/tests/services/__init__.py similarity index 100% rename from tests/bss_web_file_server/routers/__init__.py rename to tests/services/__init__.py diff --git a/tests/bss_web_file_server/services/mountains.jpg b/tests/services/mountains.jpg similarity index 100% rename from tests/bss_web_file_server/services/mountains.jpg rename to tests/services/mountains.jpg diff --git a/tests/bss_web_file_server/services/test_image.py b/tests/services/test_image.py similarity index 91% rename from tests/bss_web_file_server/services/test_image.py rename to tests/services/test_image.py index 8a8d91f..3ee36f8 100644 --- a/tests/bss_web_file_server/services/test_image.py +++ b/tests/services/test_image.py @@ -1,6 +1,6 @@ from pathlib import Path -from bss_web_file_server.services.image import ImgFormat, create_images +from src.services.image import ImgFormat, create_images def test_create_images(tmp_path): diff --git a/tests/bss_web_file_server/services/test_member.py b/tests/services/test_member.py similarity index 91% rename from tests/bss_web_file_server/services/test_member.py rename to tests/services/test_member.py index f894b11..54cfb94 100644 --- a/tests/bss_web_file_server/services/test_member.py +++ b/tests/services/test_member.py @@ -3,8 +3,8 @@ import pytest -from bss_web_file_server.models.member import Member -from bss_web_file_server.services.member import MemberService +from src.models.member import Member +from src.services.member import MemberService id = uuid4() member = Member(id=id, url="test_url") @@ -58,9 +58,7 @@ def test_update_symlink_no_id(member_service): def test_create_profile_picture(member_service, mocker): - mock_create_images = mocker.patch( - "bss_web_file_server.services.member.create_images" - ) + mock_create_images = mocker.patch("src.services.member.create_images") mock_create_images.return_value = None member_service.create_folder_structure(member) diff --git a/tests/bss_web_file_server/services/test_video.py b/tests/services/test_video.py similarity index 91% rename from tests/bss_web_file_server/services/test_video.py rename to tests/services/test_video.py index 7f549af..3c08f70 100644 --- a/tests/bss_web_file_server/services/test_video.py +++ b/tests/services/test_video.py @@ -3,8 +3,8 @@ import pytest -from bss_web_file_server.models.video import Video -from bss_web_file_server.services.video import VideoService +from src.models.video import Video +from src.services.video import VideoService id = uuid4() video = Video(id=id, urls=["test_url0", "test_url1"]) @@ -61,9 +61,7 @@ def test_update_symlink_no_id(video_service): def test_create_video_thumbnail(video_service, mocker): - mock_create_images = mocker.patch( - "bss_web_file_server.services.video.create_images" - ) + mock_create_images = mocker.patch("src.services.video.create_images") mock_create_images.return_value = None video_service.create_folder_structure(video) diff --git a/tests/bss_web_file_server/test_main.py b/tests/test_main.py similarity index 53% rename from tests/bss_web_file_server/test_main.py rename to tests/test_main.py index 6a59eac..71f0b6a 100644 --- a/tests/bss_web_file_server/test_main.py +++ b/tests/test_main.py @@ -1,14 +1,14 @@ from fastapi.testclient import TestClient from pytest_mock import MockerFixture -from bss_web_file_server.main import app +from src.main import app def test_main_startup(mocker: MockerFixture): - mock_video_service = mocker.patch("bss_web_file_server.main.video_service") - mock_member_service = mocker.patch("bss_web_file_server.main.member_service") - mock_member_service.create_base_path = mocker.AsyncMock() - mock_video_service.create_base_path = mocker.AsyncMock() + mock_video_service = mocker.patch("src.main.video_service") + mock_member_service = mocker.patch("src.main.member_service") + mock_member_service.create_base_path = mocker.Mock() + mock_video_service.create_base_path = mocker.Mock() with TestClient(app) as client: response = client.get("/docs")