[test] mock generate_signature for speed up test
Some checks failed
/ run-pytest (push) Failing after 36s

This commit is contained in:
SouthFox 2024-09-30 00:28:20 +08:00
parent 03e5b5f2f3
commit d3246e12cf
3 changed files with 24 additions and 5 deletions

19
poetry.lock generated
View file

@ -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"

View file

@ -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]

View file

@ -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