mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2024-10-01 03:35:38 -04:00
tests: Test that we're sending out user updates from the daemon.
This commit is contained in:
parent
62d0e5607e
commit
9308dfec3f
@ -125,11 +125,43 @@ async def pan_proxy_server(tempdir, aiohttp_server):
|
||||
|
||||
server = await aiohttp_server(app)
|
||||
|
||||
yield server, proxy
|
||||
yield server, proxy, (pan_queue, ui_queue)
|
||||
|
||||
await proxy.shutdown(app)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def running_proxy(pan_proxy_server, aioresponse, aiohttp_client):
|
||||
server, proxy, queues = pan_proxy_server
|
||||
|
||||
login_response = {
|
||||
"access_token": "abc123",
|
||||
"device_id": "GHTYAJCE",
|
||||
"home_server": "example.org",
|
||||
"user_id": "@example:example.org"
|
||||
}
|
||||
|
||||
aioclient = await aiohttp_client(server)
|
||||
|
||||
aioresponse.post(
|
||||
"https://example.org/_matrix/client/r0/login",
|
||||
status=200,
|
||||
payload=login_response,
|
||||
repeat=True
|
||||
)
|
||||
|
||||
await aioclient.post(
|
||||
"/_matrix/client/r0/login",
|
||||
json={
|
||||
"type": "m.login.password",
|
||||
"user": "example",
|
||||
"password": "wordpass",
|
||||
}
|
||||
)
|
||||
|
||||
yield server, aioclient, proxy, queues
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def aioresponse():
|
||||
with aioresponses(passthrough=["http://127.0.0.1"]) as m:
|
||||
|
@ -5,6 +5,7 @@ import re
|
||||
from aiohttp import web
|
||||
|
||||
from conftest import faker
|
||||
from pantalaimon.thread_messages import UpdateUsersMessage
|
||||
|
||||
|
||||
class TestClass(object):
|
||||
@ -36,7 +37,7 @@ class TestClass(object):
|
||||
}
|
||||
|
||||
async def test_daemon_start(self, pan_proxy_server, aiohttp_client, aioresponse):
|
||||
server, daemon = pan_proxy_server
|
||||
server, daemon, _ = pan_proxy_server
|
||||
|
||||
client = await aiohttp_client(server)
|
||||
|
||||
@ -70,7 +71,7 @@ class TestClass(object):
|
||||
assert pan_client.task
|
||||
|
||||
async def test_pan_client_sync(self, pan_proxy_server, aiohttp_client, aioresponse):
|
||||
server, daemon = pan_proxy_server
|
||||
server, daemon, _ = pan_proxy_server
|
||||
|
||||
client = await aiohttp_client(server)
|
||||
|
||||
@ -105,7 +106,7 @@ class TestClass(object):
|
||||
assert len(pan_client.rooms) == 1
|
||||
|
||||
async def test_pan_client_keys_upload(self, pan_proxy_server, aiohttp_client, aioresponse):
|
||||
server, daemon = pan_proxy_server
|
||||
server, daemon, _ = pan_proxy_server
|
||||
|
||||
client = await aiohttp_client(server)
|
||||
|
||||
@ -148,3 +149,15 @@ class TestClass(object):
|
||||
pan_client = list(daemon.pan_clients.values())[0]
|
||||
|
||||
assert pan_client.olm.account.shared
|
||||
|
||||
async def test_server_users_update(self, running_proxy):
|
||||
_, _, _, queues = running_proxy
|
||||
queue, _ = queues
|
||||
queue = queue.sync_q
|
||||
|
||||
message = queue.get_nowait()
|
||||
|
||||
assert isinstance(message, UpdateUsersMessage)
|
||||
|
||||
assert message.user_id == "@example:example.org"
|
||||
assert message.device_id == "GHTYAJCE"
|
||||
|
Loading…
Reference in New Issue
Block a user