From 24b6f8245d035c83a2d93ce2731c1725656d3d75 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sun, 20 Aug 2023 11:54:40 -0400 Subject: [PATCH] refactor(backend): modularize files logic (#33) * refactor(backend): consolidate files logic in module * refactor(backend): move tests to match existing pattern --- backend/rotini/auth/routes.py | 2 +- backend/rotini/auth/use_cases.py | 2 +- backend/rotini/{use_cases => }/exceptions.py | 0 backend/rotini/{api => files}/__init__.py | 0 backend/rotini/{api/files.py => files/routes.py} | 4 +++- backend/rotini/{use_cases/files.py => files/use_cases.py} | 3 ++- backend/rotini/main.py | 2 +- backend/rotini/use_cases/__init__.py | 0 backend/tests/{test_api_files.py => test_files_routes.py} | 0 backend/tests/test_stub.py | 2 -- 10 files changed, 8 insertions(+), 7 deletions(-) rename backend/rotini/{use_cases => }/exceptions.py (100%) rename backend/rotini/{api => files}/__init__.py (100%) rename backend/rotini/{api/files.py => files/routes.py} (98%) rename backend/rotini/{use_cases/files.py => files/use_cases.py} (98%) delete mode 100644 backend/rotini/use_cases/__init__.py rename backend/tests/{test_api_files.py => test_files_routes.py} (100%) delete mode 100644 backend/tests/test_stub.py diff --git a/backend/rotini/auth/routes.py b/backend/rotini/auth/routes.py index 26d63ff..f1cb46f 100644 --- a/backend/rotini/auth/routes.py +++ b/backend/rotini/auth/routes.py @@ -1,6 +1,6 @@ from fastapi import APIRouter, HTTPException -from use_cases.exceptions import DoesNotExist +from exceptions import DoesNotExist import auth.use_cases as auth_use_cases import auth.base as auth_base diff --git a/backend/rotini/auth/use_cases.py b/backend/rotini/auth/use_cases.py index a6402fa..c8e8d5b 100644 --- a/backend/rotini/auth/use_cases.py +++ b/backend/rotini/auth/use_cases.py @@ -9,7 +9,7 @@ import typing_extensions as typing import argon2 from db import get_connection -from use_cases.exceptions import DoesNotExist +from exceptions import DoesNotExist import auth.base as auth_base diff --git a/backend/rotini/use_cases/exceptions.py b/backend/rotini/exceptions.py similarity index 100% rename from backend/rotini/use_cases/exceptions.py rename to backend/rotini/exceptions.py diff --git a/backend/rotini/api/__init__.py b/backend/rotini/files/__init__.py similarity index 100% rename from backend/rotini/api/__init__.py rename to backend/rotini/files/__init__.py diff --git a/backend/rotini/api/files.py b/backend/rotini/files/routes.py similarity index 98% rename from backend/rotini/api/files.py rename to backend/rotini/files/routes.py index d7178cc..420ca7a 100644 --- a/backend/rotini/api/files.py +++ b/backend/rotini/files/routes.py @@ -9,7 +9,9 @@ import pathlib from fastapi import APIRouter, HTTPException, UploadFile from fastapi.responses import FileResponse -import use_cases.files as files_use_cases + +import files.use_cases as files_use_cases + from settings import settings router = APIRouter(prefix="/files") diff --git a/backend/rotini/use_cases/files.py b/backend/rotini/files/use_cases.py similarity index 98% rename from backend/rotini/use_cases/files.py rename to backend/rotini/files/use_cases.py index 09785f9..011a204 100644 --- a/backend/rotini/use_cases/files.py +++ b/backend/rotini/files/use_cases.py @@ -11,7 +11,8 @@ import typing_extensions as typing from db import get_connection from settings import settings -from use_cases.exceptions import DoesNotExist + +from exceptions import DoesNotExist class FileRecord(typing.TypedDict): diff --git a/backend/rotini/main.py b/backend/rotini/main.py index d81ef0d..7b8bf17 100644 --- a/backend/rotini/main.py +++ b/backend/rotini/main.py @@ -5,7 +5,7 @@ from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware import auth.routes as auth_routes -import api.files as files_routes +import files.routes as files_routes app = FastAPI() diff --git a/backend/rotini/use_cases/__init__.py b/backend/rotini/use_cases/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/backend/tests/test_api_files.py b/backend/tests/test_files_routes.py similarity index 100% rename from backend/tests/test_api_files.py rename to backend/tests/test_files_routes.py diff --git a/backend/tests/test_stub.py b/backend/tests/test_stub.py deleted file mode 100644 index 7e3cbdd..0000000 --- a/backend/tests/test_stub.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_stub(): - pass