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

Commit

Permalink
feat:added_connections_unit_test
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterStrob committed Sep 28, 2021
1 parent 6a9cd08 commit 7719803
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "${workspaceFolder}/env/bin/python"
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ black = "^21.6b0"
flake8 = "^3.9.2"

[tool.pytest.ini_options]
addopts = "-p no:warnings tests"
addopts = "-p no:warnings"

[build-system]
requires = ["setuptools", "poetry-core>=1.0.0"]
Expand Down
33 changes: 33 additions & 0 deletions tests/test_connections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import asyncio
from unittest.mock import patch

import pytest
from _pytest.fixtures import yield_fixture
from aries_cloudagent.connections.models.conn_record import ConnRecord
from aries_cloudagent.core.event_bus import Event
from aries_cloudagent.core.profile import Profile
from asynctest import mock

import acapy_plugin_toolbox.connections as con
import acapy_plugin_toolbox.util as util


@pytest.mark.asyncio
async def test_chandler(profile):
"""Connections handler tester.
Runs connections_event_handler() and returns
the output."""
with patch.object(con, 'send_to_admins',
mock.CoroutineMock()) as mocked_send_to_admins:
event = Event(
f"acapy::record::{ConnRecord.RECORD_TOPIC}::{ConnRecord.State.RESPONSE}",
ConnRecord(state=ConnRecord.State.RESPONSE).serialize()
)

await con.connections_event_handler(profile, event)
mocked_send_to_admins.assert_called_once()


if __name__ == "__main__":
pytest.run(test_chandler())

0 comments on commit 7719803

Please sign in to comment.