forked from forks/microblog.pub
Tweak test suite
This commit is contained in:
parent
55cbd8b617
commit
4d0f439c8c
2 changed files with 6 additions and 23 deletions
|
@ -4,11 +4,11 @@ import pytest
|
|||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.database import Base
|
||||
from app.database import SessionLocal
|
||||
from app.database import async_engine
|
||||
from app.database import async_session
|
||||
from app.database import engine
|
||||
from app.main import app
|
||||
from tests.factories import _Session
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -25,28 +25,12 @@ async def async_db_session():
|
|||
def db() -> Generator:
|
||||
Base.metadata.create_all(bind=engine)
|
||||
try:
|
||||
yield SessionLocal()
|
||||
yield _Session
|
||||
finally:
|
||||
try:
|
||||
Base.metadata.drop_all(bind=engine)
|
||||
except Exception:
|
||||
# XXX: for some reason, the teardown occasionally fails because of this
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def exclude_fastapi_middleware():
|
||||
"""Workaround for https://github.com/encode/starlette/issues/472"""
|
||||
user_middleware = app.user_middleware.copy()
|
||||
app.user_middleware = []
|
||||
app.middleware_stack = app.build_middleware_stack()
|
||||
yield
|
||||
app.user_middleware = user_middleware
|
||||
app.middleware_stack = app.build_middleware_stack()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(db, exclude_fastapi_middleware) -> Generator:
|
||||
# app.dependency_overrides[get_db] = _get_db_for_testing
|
||||
def client(db) -> Generator:
|
||||
with TestClient(app) as c:
|
||||
yield c
|
||||
|
|
|
@ -56,6 +56,7 @@ async def test_new_outgoing_activity(
|
|||
outgoing_activity = await new_outgoing_activity(
|
||||
async_db_session, inbox_url, outbox_object.id
|
||||
)
|
||||
await async_db_session.commit()
|
||||
|
||||
assert (
|
||||
await async_db_session.execute(select(models.OutgoingActivity))
|
||||
|
@ -105,8 +106,6 @@ def test_process_next_outgoing_activity__webmention(
|
|||
db: Session,
|
||||
respx_mock: respx.MockRouter,
|
||||
) -> None:
|
||||
# FIXME(ts): fix not passing in CI (but passing in local)
|
||||
return
|
||||
# And an outgoing activity
|
||||
outbox_object = _setup_outbox_object()
|
||||
|
||||
|
@ -176,7 +175,7 @@ def test_process_next_outgoing_activity__errored(
|
|||
)
|
||||
|
||||
# And an outgoing activity
|
||||
outgoing_activity = factories.OutgoingActivityFactory(
|
||||
outgoing_activity = factories.OutgoingActivityFactory.create(
|
||||
recipient=recipient_inbox_url,
|
||||
outbox_object_id=outbox_object.id,
|
||||
inbox_object_id=None,
|
||||
|
|
Loading…
Reference in a new issue