mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-13 05:58:35 +03:00
refactoring worker file location
This commit is contained in:
@@ -31,7 +31,7 @@ services:
|
|||||||
|
|
||||||
worker:
|
worker:
|
||||||
<<: *base-setup
|
<<: *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:
|
volumes:
|
||||||
- ./src:/app
|
- ./src:/app
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import sqlalchemy
|
|||||||
|
|
||||||
from web.security import token_api_key_auth
|
from web.security import token_api_key_auth
|
||||||
from db import models, schemas
|
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
|
from core.logging import log_error
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from loguru import logger
|
|||||||
from core.config import ALLOW_ANY_EMAIL
|
from core.config import ALLOW_ANY_EMAIL
|
||||||
from web.security import get_token_or_user_auth
|
from web.security import get_token_or_user_auth
|
||||||
from db import schemas
|
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"])
|
sheet_router = APIRouter(prefix="/sheet", tags=["Google Spreadsheet operations"])
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from web.security import get_token_or_user_auth
|
|||||||
|
|
||||||
from db import schemas
|
from db import schemas
|
||||||
from core.logging import log_error
|
from core.logging import log_error
|
||||||
from worker import celery
|
from worker.main import celery
|
||||||
|
|
||||||
|
|
||||||
task_router = APIRouter(prefix="/task", tags=["Async task operations"])
|
task_router = APIRouter(prefix="/task", tags=["Async task operations"])
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from sqlalchemy.orm import Session
|
|||||||
from db import crud, schemas
|
from db import crud, schemas
|
||||||
from db.database import get_db_dependency
|
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"])
|
url_router = APIRouter(prefix="/url", tags=["Single URL operations"])
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ def test_sheet_no_auth(client, test_no_auth):
|
|||||||
test_no_auth(client.post, "/sheet/archive")
|
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):
|
def test_sheet_rick(m1, client_with_auth):
|
||||||
|
|
||||||
response = client_with_auth.post("/sheet/archive", json={"sheet_id": "123-sheet-id"})
|
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"}
|
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):
|
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"})
|
response = client.post("/sheet/archive", json={"sheet_name": "456-sheet_name-id"}, headers={"Authorization": "Bearer this_is_the_test_api_token"})
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ def test_archive_url_unauthenticated(client, test_no_auth):
|
|||||||
test_no_auth(client.get, "/url/archive")
|
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):
|
def test_archive_url(m1, client_with_auth):
|
||||||
response = client_with_auth.post("/url/archive", json={"url": "bad"})
|
response = client_with_auth.post("/url/archive", json={"url": "bad"})
|
||||||
assert response.status_code == 422
|
assert response.status_code == 422
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from sqlalchemy.orm import Session
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from core.logging import logging_middleware, log_error
|
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 db import crud, models, schemas
|
||||||
from web.security import get_user_auth, token_api_key_auth, get_token_or_user_auth
|
from web.security import get_user_auth, token_api_key_auth, get_token_or_user_auth
|
||||||
|
|||||||
0
src/worker/__init__.py
Normal file
0
src/worker/__init__.py
Normal file
Reference in New Issue
Block a user