From 189d686a451833bb2090888392ad7c39bfea3767 Mon Sep 17 00:00:00 2001 From: Juliano Fernandes Date: Fri, 10 May 2024 17:11:41 -0300 Subject: [PATCH] refactor: move services modules to a more appropriate subpackage --- fastapi_utils/services/__init__.py | 0 fastapi_utils/{dependencies => services}/cloud_storage.py | 0 fastapi_utils/{ => services}/protocols.py | 0 fastapi_utils/{dependencies => services}/pubsub.py | 0 tests/services/__init__.py | 0 tests/{dependencies => services}/test_cloud_storage.py | 5 ++--- tests/{dependencies => services}/test_pubsub.py | 5 ++--- 7 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 fastapi_utils/services/__init__.py rename fastapi_utils/{dependencies => services}/cloud_storage.py (100%) rename fastapi_utils/{ => services}/protocols.py (100%) rename fastapi_utils/{dependencies => services}/pubsub.py (100%) create mode 100644 tests/services/__init__.py rename tests/{dependencies => services}/test_cloud_storage.py (81%) rename tests/{dependencies => services}/test_pubsub.py (88%) diff --git a/fastapi_utils/services/__init__.py b/fastapi_utils/services/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/fastapi_utils/dependencies/cloud_storage.py b/fastapi_utils/services/cloud_storage.py similarity index 100% rename from fastapi_utils/dependencies/cloud_storage.py rename to fastapi_utils/services/cloud_storage.py diff --git a/fastapi_utils/protocols.py b/fastapi_utils/services/protocols.py similarity index 100% rename from fastapi_utils/protocols.py rename to fastapi_utils/services/protocols.py diff --git a/fastapi_utils/dependencies/pubsub.py b/fastapi_utils/services/pubsub.py similarity index 100% rename from fastapi_utils/dependencies/pubsub.py rename to fastapi_utils/services/pubsub.py diff --git a/tests/services/__init__.py b/tests/services/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/dependencies/test_cloud_storage.py b/tests/services/test_cloud_storage.py similarity index 81% rename from tests/dependencies/test_cloud_storage.py rename to tests/services/test_cloud_storage.py index 9de4989..e2b3be7 100644 --- a/tests/dependencies/test_cloud_storage.py +++ b/tests/services/test_cloud_storage.py @@ -2,8 +2,7 @@ import pytest -from fastapi_utils.dependencies import cloud_storage -from fastapi_utils.protocols import Uploader +from fastapi_utils.services import cloud_storage, protocols @pytest.fixture @@ -17,7 +16,7 @@ def storage_mock(monkeypatch: pytest.MonkeyPatch) -> MagicMock: def test_uploader(storage_mock: MagicMock): uploader = cloud_storage.Uploader() - assert isinstance(uploader, Uploader) + assert isinstance(uploader, protocols.Uploader) uploader.upload("test-bucket", "destination.txt", "source.txt") diff --git a/tests/dependencies/test_pubsub.py b/tests/services/test_pubsub.py similarity index 88% rename from tests/dependencies/test_pubsub.py rename to tests/services/test_pubsub.py index 3d2ddee..c3d4572 100644 --- a/tests/dependencies/test_pubsub.py +++ b/tests/services/test_pubsub.py @@ -5,8 +5,7 @@ from fastapi.encoders import jsonable_encoder from pydantic import BaseModel -from fastapi_utils.dependencies import pubsub -from fastapi_utils.protocols import Publisher +from fastapi_utils.services import protocols, pubsub MAGIC_NUMBER = "42" @@ -29,7 +28,7 @@ def pubsub_mock(monkeypatch: pytest.MonkeyPatch) -> MagicMock: def test_publisher(pubsub_mock: MagicMock): publisher = pubsub.Publisher() - assert isinstance(publisher, Publisher) + assert isinstance(publisher, protocols.Publisher) topic = "projects/test-project/topics/test-topic" message = MessageTest(content="test")