Newer
Older
import pytest
from fastapi.testclient import TestClient
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY
from service.core.settings import settings
from service.main import app
client = TestClient(app)
@pytest.mark.integration
def test_create_conversion_returns_result():
response = client.post(
"/conversions",
json={
"source_url": f"{settings.S3_ENDPOINT}/{settings.S3_BUCKET}/my-fake-file",
},
)
assert response.json() == {
"id": 1,
"result_url": None,
"source_url": f"{settings.S3_ENDPOINT}/{settings.S3_BUCKET}/my-fake-file",
"status": "pending",
}
@pytest.mark.integration
def test_create_conversion_with_bad_source_returns_422():
response = client.post(
"/conversions",
json={
"source_url": f"not-the-endpoint-{settings.S3_ENDPOINT}/{settings.S3_BUCKET}/my-fake-file",
},
)
assert response.status_code == HTTP_422_UNPROCESSABLE_ENTITY