drop ahriman.core.triggers.Trigger.run method

In order to force new triggers to use on_result method, the old method
has been removed. However, default on_result method still checks if the
old method exists and tries to run it
This commit is contained in:
2022-10-19 20:07:31 +03:00
parent c1d74726b7
commit 1e8388af5d
2 changed files with 14 additions and 24 deletions

View File

@ -1,14 +1,23 @@
from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from ahriman.core.triggers import Trigger
from ahriman.models.result import Result
def test_on_result(trigger: Trigger, mocker: MockerFixture) -> None:
def test_on_result(trigger: Trigger) -> None:
"""
must pass execution nto run method
"""
run_mock = mocker.patch("ahriman.core.triggers.Trigger.run")
trigger.on_result(Result(), [])
def test_on_result_run(trigger: Trigger) -> None:
"""
must fallback to run method if it exists
"""
run_mock = MagicMock()
setattr(trigger, "run", run_mock)
trigger.on_result(Result(), [])
run_mock.assert_called_once_with(Result(), [])
@ -25,10 +34,3 @@ def test_on_stop(trigger: Trigger) -> None:
must do nothing for not implemented method on_stop
"""
trigger.on_stop()
def test_run(trigger: Trigger) -> None:
"""
must do nothing for not implemented method run
"""
trigger.run(Result(), [])