From 847780b473e7bdf99ce83f29ba64a29bb7f16e01 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 17 Jun 2022 15:50:34 +0200 Subject: [PATCH] tests (unit/ap gateway): fix `onMessage` call following change in the component: the component now uses the normal message workflow, thus the tests had to be updated rel 367 --- tests/unit/test_ap-gateway.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/unit/test_ap-gateway.py b/tests/unit/test_ap-gateway.py index ce9598e0..f678db03 100644 --- a/tests/unit/test_ap-gateway.py +++ b/tests/unit/test_ap-gateway.py @@ -823,12 +823,17 @@ class TestActivityPubGateway: monkeypatch.setattr(plugin_comp_ap_gateway.treq, "get", mock_ap_get) monkeypatch.setattr(plugin_comp_ap_gateway.treq, "json_content", mock_treq_json) monkeypatch.setattr(ap_gateway, "apGet", mock_ap_get) - message_elt = domish.Element((None, "message")) - message_elt.addElement("body", content="This is a test message.") - message_elt["from"] = TEST_JID.full() - message_elt["to"] = ap_gateway.getLocalJIDFromAccount(TEST_AP_ACCOUNT).full() + mess_data = { + "from": TEST_JID, + "to": ap_gateway.getLocalJIDFromAccount(TEST_AP_ACCOUNT), + "type": "chat", + "message": {"": "This is a test message."}, + "extra": { + "origin-id": "123" + } + } with patch.object(ap_gateway, "signAndPost") as signAndPost: - await ap_gateway.onMessage(message_elt) + await ap_gateway.onMessage(ap_gateway.client, mess_data) url, actor_id, doc = signAndPost.call_args[0] assert url == "https://example.org/users/test_user/inbox" assert actor_id == "https://test.example/_ap/actor/some_user%40test.example"