Skip to content

Commit

Permalink
Remove packages (#66)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
csikb authored Mar 20, 2024
1 parent 32344bb commit 9f4606c
Show file tree
Hide file tree
Showing 30 changed files with 36 additions and 40 deletions.
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
[tool.poetry]
name = "bss-web-file-server"
version = "0.1.0"
description = "BSS file server API"
authors = ["Bence Csik <[email protected]>"]
readme = "README.md"
packages = [{include = "bss_web_file_server", from = "src"}]
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
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"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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

Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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

Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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

Expand Down
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions tests/bss_web_file_server/test_main.py → tests/test_main.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 9f4606c

Please sign in to comment.