chore(matrix_notification): add test for check_mode

This commit is contained in:
Johanna Dorothea Reichmann 2023-01-31 12:05:55 +01:00
parent 6230aedc25
commit fb0cee0053
No known key found for this signature in database
GPG key ID: 03624C433676E465

View file

@ -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)