Skip to content
This repository was archived by the owner on Sep 22, 2023. It is now read-only.

Commit 7719803

Browse files
committed
feat:added_connections_unit_test
1 parent 6a9cd08 commit 7719803

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "${workspaceFolder}/env/bin/python"
3+
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ black = "^21.6b0"
4747
flake8 = "^3.9.2"
4848

4949
[tool.pytest.ini_options]
50-
addopts = "-p no:warnings tests"
50+
addopts = "-p no:warnings"
5151

5252
[build-system]
5353
requires = ["setuptools", "poetry-core>=1.0.0"]

tests/test_connections.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import asyncio
2+
from unittest.mock import patch
3+
4+
import pytest
5+
from _pytest.fixtures import yield_fixture
6+
from aries_cloudagent.connections.models.conn_record import ConnRecord
7+
from aries_cloudagent.core.event_bus import Event
8+
from aries_cloudagent.core.profile import Profile
9+
from asynctest import mock
10+
11+
import acapy_plugin_toolbox.connections as con
12+
import acapy_plugin_toolbox.util as util
13+
14+
15+
@pytest.mark.asyncio
16+
async def test_chandler(profile):
17+
"""Connections handler tester.
18+
19+
Runs connections_event_handler() and returns
20+
the output."""
21+
with patch.object(con, 'send_to_admins',
22+
mock.CoroutineMock()) as mocked_send_to_admins:
23+
event = Event(
24+
f"acapy::record::{ConnRecord.RECORD_TOPIC}::{ConnRecord.State.RESPONSE}",
25+
ConnRecord(state=ConnRecord.State.RESPONSE).serialize()
26+
)
27+
28+
await con.connections_event_handler(profile, event)
29+
mocked_send_to_admins.assert_called_once()
30+
31+
32+
if __name__ == "__main__":
33+
pytest.run(test_chandler())

0 commit comments

Comments
 (0)