diff --git a/docker-compose.yml b/docker-compose.yml index 5650f74..2274dca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,7 +31,7 @@ services: worker: <<: *base-setup - command: celery --app=worker.celery worker --loglevel=info --logfile=logs/celery.log + command: celery --app=worker.main.celery worker --loglevel=info --logfile=logs/celery.log volumes: - ./src:/app - /var/run/docker.sock:/var/run/docker.sock diff --git a/src/endpoints/interoperability.py b/src/endpoints/interoperability.py index b784e03..5758dc1 100644 --- a/src/endpoints/interoperability.py +++ b/src/endpoints/interoperability.py @@ -6,7 +6,7 @@ import sqlalchemy from web.security import token_api_key_auth from db import models, schemas -from worker import insert_result_into_db +from worker.main import insert_result_into_db from core.logging import log_error diff --git a/src/endpoints/sheet.py b/src/endpoints/sheet.py index ecde4f4..5a75c89 100644 --- a/src/endpoints/sheet.py +++ b/src/endpoints/sheet.py @@ -7,7 +7,7 @@ from loguru import logger from core.config import ALLOW_ANY_EMAIL from web.security import get_token_or_user_auth from db import schemas -from worker import create_sheet_task +from worker.main import create_sheet_task sheet_router = APIRouter(prefix="/sheet", tags=["Google Spreadsheet operations"]) diff --git a/src/endpoints/task.py b/src/endpoints/task.py index 532bad6..1a0c6ac 100644 --- a/src/endpoints/task.py +++ b/src/endpoints/task.py @@ -8,7 +8,7 @@ from web.security import get_token_or_user_auth from db import schemas from core.logging import log_error -from worker import celery +from worker.main import celery task_router = APIRouter(prefix="/task", tags=["Async task operations"]) diff --git a/src/endpoints/url.py b/src/endpoints/url.py index 9a59b77..3932f73 100644 --- a/src/endpoints/url.py +++ b/src/endpoints/url.py @@ -10,7 +10,7 @@ from sqlalchemy.orm import Session from db import crud, schemas from db.database import get_db_dependency -from worker import create_archive_task +from worker.main import create_archive_task url_router = APIRouter(prefix="/url", tags=["Single URL operations"]) diff --git a/src/tests/endpoints/test_sheet.py b/src/tests/endpoints/test_sheet.py index 1c0838f..f3e2559 100644 --- a/src/tests/endpoints/test_sheet.py +++ b/src/tests/endpoints/test_sheet.py @@ -8,7 +8,7 @@ def test_sheet_no_auth(client, test_no_auth): test_no_auth(client.post, "/sheet/archive") -@patch("worker.create_sheet_task.delay", return_value=TaskResult(id="123-456-789", status="PENDING", result="")) +@patch("worker.main.create_sheet_task.delay", return_value=TaskResult(id="123-456-789", status="PENDING", result="")) def test_sheet_rick(m1, client_with_auth): response = client_with_auth.post("/sheet/archive", json={"sheet_id": "123-sheet-id"}) @@ -26,7 +26,7 @@ def test_sheet_missing_sheet_data(client_with_auth): assert r.json() == {"detail": "sheet name or id is required"} -@patch("worker.create_sheet_task.delay", return_value=TaskResult(id="123-API-789", status="PENDING", result="")) +@patch("worker.main.create_sheet_task.delay", return_value=TaskResult(id="123-API-789", status="PENDING", result="")) def test_sheet_api(m1, client): response = client.post("/sheet/archive", json={"sheet_name": "456-sheet_name-id"}, headers={"Authorization": "Bearer this_is_the_test_api_token"}) diff --git a/src/tests/endpoints/test_url.py b/src/tests/endpoints/test_url.py index b128493..01b6a24 100644 --- a/src/tests/endpoints/test_url.py +++ b/src/tests/endpoints/test_url.py @@ -10,7 +10,7 @@ def test_archive_url_unauthenticated(client, test_no_auth): test_no_auth(client.get, "/url/archive") -@patch("worker.create_archive_task.delay", return_value=TaskResult(id="123-456-789", status="PENDING", result="")) +@patch("worker.main.create_archive_task.delay", return_value=TaskResult(id="123-456-789", status="PENDING", result="")) def test_archive_url(m1, client_with_auth): response = client_with_auth.post("/url/archive", json={"url": "bad"}) assert response.status_code == 422 diff --git a/src/web/main.py b/src/web/main.py index addc3a9..adc837d 100644 --- a/src/web/main.py +++ b/src/web/main.py @@ -12,7 +12,7 @@ from sqlalchemy.orm import Session from loguru import logger from core.logging import logging_middleware, log_error -from worker import create_archive_task, create_sheet_task, celery, insert_result_into_db +from worker.main import create_archive_task, create_sheet_task, celery, insert_result_into_db from db import crud, models, schemas from web.security import get_user_auth, token_api_key_auth, get_token_or_user_auth diff --git a/src/worker/__init__.py b/src/worker/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/worker.py b/src/worker/main.py similarity index 100% rename from src/worker.py rename to src/worker/main.py