mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-04-07 19:03:38 +00:00
Compare commits
2 Commits
bfb51434a0
...
1f4d2a50b1
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f4d2a50b1 | |||
| 96684d7ddd |
@@ -127,6 +127,7 @@ def application(configuration: Configuration, spawner: Spawn, database: SQLite,
|
|||||||
Application: application test instance
|
Application: application test instance
|
||||||
"""
|
"""
|
||||||
configuration.set_option("web", "port", "8080")
|
configuration.set_option("web", "port", "8080")
|
||||||
|
mocker.patch("ahriman.core.configuration.Configuration.from_path", return_value=configuration)
|
||||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||||
mocker.patch("aiohttp_apispec.setup_aiohttp_apispec")
|
mocker.patch("aiohttp_apispec.setup_aiohttp_apispec")
|
||||||
mocker.patch.object(helpers, "aiohttp_security", None)
|
mocker.patch.object(helpers, "aiohttp_security", None)
|
||||||
@@ -153,6 +154,7 @@ def application_with_auth(configuration: Configuration, user: User, spawner: Spa
|
|||||||
"""
|
"""
|
||||||
configuration.set_option("auth", "target", "configuration")
|
configuration.set_option("auth", "target", "configuration")
|
||||||
configuration.set_option("web", "port", "8080")
|
configuration.set_option("web", "port", "8080")
|
||||||
|
mocker.patch("ahriman.core.configuration.Configuration.from_path", return_value=configuration)
|
||||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||||
mocker.patch("aiohttp_apispec.setup_aiohttp_apispec")
|
mocker.patch("aiohttp_apispec.setup_aiohttp_apispec")
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
|
|||||||
@@ -61,6 +61,21 @@ def test_create_socket_safe(application: Application, mocker: MockerFixture) ->
|
|||||||
chmod_mock.assert_not_called()
|
chmod_mock.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_watcher(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||||
|
"""
|
||||||
|
must create watcher for repository
|
||||||
|
"""
|
||||||
|
mocker.patch("ahriman.core.configuration.Configuration.from_path", return_value=configuration)
|
||||||
|
database_mock = mocker.patch("ahriman.core.database.SQLite.load")
|
||||||
|
client_mock = mocker.patch("ahriman.core.status.Client.load")
|
||||||
|
configuration_path, repository_id = configuration.check_loaded()
|
||||||
|
|
||||||
|
result = _create_watcher(configuration_path, repository_id)
|
||||||
|
assert isinstance(result, Watcher)
|
||||||
|
database_mock.assert_called_once()
|
||||||
|
client_mock.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
async def test_on_shutdown(application: Application, mocker: MockerFixture) -> None:
|
async def test_on_shutdown(application: Application, mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
must write information to log
|
must write information to log
|
||||||
@@ -139,20 +154,6 @@ def test_run_with_socket(application: Application, mocker: MockerFixture) -> Non
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_create_watcher(configuration: Configuration, mocker: MockerFixture) -> None:
|
|
||||||
"""
|
|
||||||
must create watcher for repository
|
|
||||||
"""
|
|
||||||
database_mock = mocker.patch("ahriman.core.database.SQLite.load")
|
|
||||||
client_mock = mocker.patch("ahriman.core.status.Client.load")
|
|
||||||
configuration_path, repository_id = configuration.check_loaded()
|
|
||||||
|
|
||||||
result = _create_watcher(configuration_path, repository_id)
|
|
||||||
assert isinstance(result, Watcher)
|
|
||||||
database_mock.assert_called_once()
|
|
||||||
client_mock.assert_called_once()
|
|
||||||
|
|
||||||
|
|
||||||
def test_setup_no_repositories(configuration: Configuration, spawner: Spawn) -> None:
|
def test_setup_no_repositories(configuration: Configuration, spawner: Spawn) -> None:
|
||||||
"""
|
"""
|
||||||
must raise InitializeError if no repositories set
|
must raise InitializeError if no repositories set
|
||||||
|
|||||||
Reference in New Issue
Block a user