mirror of
https://github.com/famedly/ansible-collection-matrix
synced 2024-11-10 13:44:16 +00:00
chore(matrix_notification): add test for check_mode
This commit is contained in:
parent
6230aedc25
commit
fb0cee0053
1 changed files with 20 additions and 0 deletions
|
@ -18,6 +18,7 @@ from ansible_collections.famedly.matrix.tests.unit.mock_nio.room import failure
|
|||
from ansible_collections.famedly.matrix.tests.unit.utils import (
|
||||
AnsibleExitJson,
|
||||
AnsibleFailJson,
|
||||
assert_expression,
|
||||
set_module_args,
|
||||
exit_json,
|
||||
fail_json,
|
||||
|
@ -58,6 +59,7 @@ class TestAnsibleModuleMatrixNotification:
|
|||
with pytest.raises(AnsibleExitJson) as result:
|
||||
matrix_notification.main()
|
||||
ansible_result = result.value.result
|
||||
assert_expression(ansible_result["changed"] is True)
|
||||
|
||||
def test_notification_fail(self, monkeypatch):
|
||||
class TestClass(failure.RoomSend, MatrixNioSuccess):
|
||||
|
@ -77,3 +79,21 @@ class TestAnsibleModuleMatrixNotification:
|
|||
with pytest.raises(AnsibleFailJson) as result:
|
||||
matrix_notification.main()
|
||||
ansible_result = result.value.result
|
||||
|
||||
def test_notification_check_mode(self, monkeypatch):
|
||||
self.patchAnsibleNioModule(monkeypatch, MatrixNioSuccess)
|
||||
set_module_args(
|
||||
{
|
||||
"hs_url": "matrix.example.tld",
|
||||
"user_id": "myuser",
|
||||
"password": "supersecretpassword",
|
||||
"room_id": "#myroom:matrix.example.tld",
|
||||
"msg_plain": "**hello world**",
|
||||
"msg_html": "<b>hello world</b>",
|
||||
},
|
||||
check_mode=True
|
||||
)
|
||||
with pytest.raises(AnsibleExitJson) as result:
|
||||
matrix_notification.main()
|
||||
ansible_result = result.value.result
|
||||
assert_expression(ansible_result["changed"] is True)
|
||||
|
|
Loading…
Reference in a new issue