diff --git a/poetry.lock b/poetry.lock index a390a7a..e86e2de 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1319,6 +1319,23 @@ files = [ pytest = ">=5.0.0" python-dotenv = ">=0.9.1" +[[package]] +name = "pytest-mock" +version = "3.14.0" +description = "Thin-wrapper around the mock package for easier use with pytest" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest-mock-3.14.0.tar.gz", hash = "sha256:2719255a1efeceadbc056d6bf3df3d1c5015530fb40cf347c0f9afac88410bd0"}, + {file = "pytest_mock-3.14.0-py3-none-any.whl", hash = "sha256:0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f"}, +] + +[package.dependencies] +pytest = ">=6.2.5" + +[package.extras] +dev = ["pre-commit", "pytest-asyncio", "tox"] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -1964,4 +1981,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] [metadata] lock-version = "2.0" python-versions = ">3.11, <3.13" -content-hash = "6fed6ea24970c03d48d0f16cc3411f836c22622c9e33c7f04260ccdd82a41d10" +content-hash = "88180fc69bca605f3f6a80d8e62a8e959731763ad3a13bc74fb1a41ebca40487" diff --git a/pyproject.toml b/pyproject.toml index 34664fd..5db5aa4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ respx = "^0.20.2" factory-boy = "^3.2.1" black = "^23.7.0" pytest-dotenv = "^0.5.2" +pytest-mock = "^3.14.0" [build-system] diff --git a/tests/test_outbox.py b/tests/test_outbox.py index 06dedda..f18102c 100644 --- a/tests/test_outbox.py +++ b/tests/test_outbox.py @@ -123,12 +123,12 @@ async def test_outbox_send_follow_request_nest_accept( async def test_outbox_send_create_activity( db: Session, async_db_session, - client: TestClient, respx_mock: respx.MockRouter, + mocker, ) -> None: # build test actor ra = build_remote_actor() - remote_ap_id = ra.ap_id # type: ignore + remote_ap_id = ra.ap_id # mock request respx_mock.get(remote_ap_id).mock( @@ -140,7 +140,8 @@ async def test_outbox_send_create_activity( from app.activitypub import VisibilityEnum from app.orgpython import to_html - async with async_db_session as db_session: #type: ignore + mocker.patch("app.ldsig.generate_signature", return_value=True) + async with async_db_session as db_session: content = "*Blod Text* =code Text= \n" content = to_html(content) @@ -153,7 +154,7 @@ async def test_outbox_send_create_activity( # And the Follow activity was created in the outbox outbox_object = db.execute(select(models.OutboxObject)).scalar_one() - assert outbox_object.ap_type == "Note" + assert "Note" == outbox_object.ap_type assert outbox_object.ap_object["content"] == content