Mercurial > libervia-backend
comparison tests/unit/test_plugin_xep_0272.py @ 4285:f1d0cde61af7
tests (unit): fix tests + black reformatting.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Jul 2024 17:42:53 +0200 |
parents | 5eb13251fd75 |
children |
comparison
equal
deleted
inserted
replaced
4284:3a550e9a2b55 | 4285:f1d0cde61af7 |
---|---|
33 from libervia.backend.tools.common import data_format | 33 from libervia.backend.tools.common import data_format |
34 | 34 |
35 TEST_ROOM_JID = jid.JID("room@example.com/user") | 35 TEST_ROOM_JID = jid.JID("room@example.com/user") |
36 | 36 |
37 | 37 |
38 | |
39 @fixture | 38 @fixture |
40 def xep_0272(host) -> XEP_0272: | 39 def xep_0272(host) -> XEP_0272: |
41 """Fixture for initializing XEP-0272 plugin.""" | 40 """Fixture for initializing XEP-0272 plugin.""" |
42 host.plugins = { | 41 host.plugins = { |
43 "XEP-0045": MagicMock(), | 42 "XEP-0045": MagicMock(), |
62 presence_elt = domish.Element((None, "presence")) | 61 presence_elt = domish.Element((None, "presence")) |
63 presence_elt["from"] = TEST_ROOM_JID.full() | 62 presence_elt["from"] = TEST_ROOM_JID.full() |
64 muji_elt = presence_elt.addElement((NS_MUJI, "muji")) | 63 muji_elt = presence_elt.addElement((NS_MUJI, "muji")) |
65 muji_elt.addElement("preparing") | 64 muji_elt.addElement("preparing") |
66 | 65 |
67 muji_data = { | 66 muji_data = {"preparing_jids": set()} |
68 "preparing_jids": set() | 67 with patch.object(xep_0272._muc, "get_room_user_jid", return_value=TEST_ROOM_JID): |
69 } | |
70 with patch.object( | |
71 xep_0272._muc, "get_room_user_jid", return_value=TEST_ROOM_JID) : | |
72 with patch.object(xep_0272, "get_muji_data", return_value=muji_data): | 68 with patch.object(xep_0272, "get_muji_data", return_value=muji_data): |
73 with patch.object( | 69 with patch.object( |
74 xep_0272, "try_to_finish_preparation" | 70 xep_0272, "try_to_finish_preparation" |
75 ) as mock_try_to_finish_preparation: | 71 ) as mock_try_to_finish_preparation: |
76 xep_0272.on_muji_request(presence_elt, client) | 72 xep_0272.on_muji_request(presence_elt, client) |
81 xep_0272 = XEP_0272(host) | 77 xep_0272 = XEP_0272(host) |
82 presence_elt = domish.Element((None, "presence")) | 78 presence_elt = domish.Element((None, "presence")) |
83 presence_elt["from"] = "room@example.com/user" | 79 presence_elt["from"] = "room@example.com/user" |
84 presence_elt.addElement((NS_MUJI, "muji")) | 80 presence_elt.addElement((NS_MUJI, "muji")) |
85 | 81 |
86 muji_data = { | 82 muji_data = {"done_preparing": True, "preparing_jids": set(), "to_call": set()} |
87 "done_preparing": True, | |
88 "preparing_jids": set(), | |
89 "to_call": set() | |
90 } | |
91 with patch.object(xep_0272, "get_muji_data", return_value=muji_data): | 83 with patch.object(xep_0272, "get_muji_data", return_value=muji_data): |
92 with patch.object( | 84 with patch.object( |
93 xep_0272, "try_to_finish_preparation" | 85 xep_0272, "try_to_finish_preparation" |
94 ) as mock_try_to_finish_preparation: | 86 ) as mock_try_to_finish_preparation: |
95 xep_0272.on_muji_request(presence_elt, client) | 87 xep_0272.on_muji_request(presence_elt, client) |