mirror of
https://github.com/bellingcat/whisperbox-transcribe.git
synced 2026-06-12 21:48:35 +03:00
feat: add language detection task
This commit is contained in:
@@ -13,7 +13,6 @@ from app.web.main import app
|
||||
def pytest_configure() -> None:
|
||||
if not database_exists(engine.url):
|
||||
create_database(engine.url)
|
||||
models.Base.metadata.create_all(engine)
|
||||
|
||||
|
||||
def pytest_unconfigure() -> None:
|
||||
@@ -21,19 +20,21 @@ def pytest_unconfigure() -> None:
|
||||
drop_database(engine.url)
|
||||
|
||||
|
||||
@pytest.fixture(name="auth_headers", scope="function")
|
||||
def auth_header() -> dict[str, str]:
|
||||
@pytest.fixture(scope="function")
|
||||
def auth_headers() -> dict[str, str]:
|
||||
return {"Authorization": f"Bearer {settings.API_SECRET}"}
|
||||
|
||||
|
||||
@pytest.fixture(name="db_session", scope="function", autouse=True)
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def db_session() -> Generator[Session, None, None]:
|
||||
models.Base.metadata.create_all(engine)
|
||||
|
||||
connection = engine.connect()
|
||||
transaction = connection.begin()
|
||||
|
||||
with SessionLocal(bind=connection) as session:
|
||||
app.dependency_overrides[get_session] = lambda: session
|
||||
yield session
|
||||
app.dependency_overrides.clear()
|
||||
transaction.rollback()
|
||||
connection.close()
|
||||
|
||||
models.Base.metadata.drop_all(bind=engine)
|
||||
|
||||
@@ -3,8 +3,6 @@ from fastapi.testclient import TestClient
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
import app.shared.db.models as models
|
||||
import app.shared.db.schemas as schemas
|
||||
from app.shared.db.schemas import JobStatus, JobType
|
||||
from app.web.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
@@ -13,7 +11,9 @@ client = TestClient(app)
|
||||
@pytest.fixture(name="mock_job", scope="function", autouse=False)
|
||||
def mock_job(db_session: Session) -> models.Job:
|
||||
job = models.Job(
|
||||
url="https://example.com", type=JobType.transcript, status=JobStatus.create
|
||||
url="https://example.com",
|
||||
type=models.JobType.transcript,
|
||||
status=models.JobStatus.create,
|
||||
)
|
||||
|
||||
db_session.add(job)
|
||||
@@ -28,7 +28,7 @@ def test_create_job_pass(auth_headers: dict[str, str]) -> None:
|
||||
res = client.post(
|
||||
"/api/v1/jobs",
|
||||
headers=auth_headers,
|
||||
json={"url": "https://example.com", "type": JobType.transcript},
|
||||
json={"url": "https://example.com", "type": models.JobType.transcript},
|
||||
)
|
||||
assert res.status_code == 201
|
||||
assert isinstance(res.json()["id"], str)
|
||||
@@ -43,7 +43,7 @@ def test_create_job_malformed_url(auth_headers: dict[str, str]) -> None:
|
||||
res = client.post(
|
||||
"/api/v1/jobs",
|
||||
headers=auth_headers,
|
||||
json={"url": "example.com", "type": JobType.transcript},
|
||||
json={"url": "example.com", "type": models.JobType.transcript},
|
||||
)
|
||||
assert res.status_code == 422
|
||||
|
||||
@@ -52,7 +52,7 @@ def test_create_job_malformed_url(auth_headers: dict[str, str]) -> None:
|
||||
# ---
|
||||
def test_get_jobs_pass(auth_headers: dict[str, str], mock_job: models.Job) -> None:
|
||||
res = client.get(
|
||||
"/api/v1/jobs?type=transcript",
|
||||
"/api/v1/jobs?type=transcribe",
|
||||
headers=auth_headers,
|
||||
)
|
||||
assert len(res.json()) == 1
|
||||
@@ -85,7 +85,7 @@ def test_get_artifacts_pass(
|
||||
auth_headers: dict[str, str], db_session: Session, mock_job: models.Job
|
||||
) -> None:
|
||||
artifact = models.Artifact(
|
||||
data=[], job_id=str(mock_job.id), type=schemas.ArtifactType.raw_transcript
|
||||
data=None, job_id=str(mock_job.id), type=models.ArtifactType.raw_transcript
|
||||
)
|
||||
|
||||
db_session.add(artifact)
|
||||
|
||||
Reference in New Issue
Block a user