mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-29 13:49:57 +00:00
constistent classmethod and staticmethod usage
General idea is to use classmethod for every constructor and statismethod otherwise. Also use self and cls whenever it's possible to call static and class methods
This commit is contained in:
@ -15,7 +15,7 @@ def test_report_failure(configuration: Configuration, mocker: MockerFixture) ->
|
||||
"""
|
||||
mocker.patch("ahriman.core.report.html.HTML.generate", side_effect=Exception())
|
||||
with pytest.raises(ReportFailed):
|
||||
Report.run("x86_64", configuration, ReportSettings.HTML.name, Path("path"))
|
||||
Report.load("x86_64", configuration, ReportSettings.HTML.name).run(Path("path"))
|
||||
|
||||
|
||||
def test_report_html(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
@ -23,5 +23,5 @@ def test_report_html(configuration: Configuration, mocker: MockerFixture) -> Non
|
||||
must generate html report
|
||||
"""
|
||||
report_mock = mocker.patch("ahriman.core.report.html.HTML.generate")
|
||||
Report.run("x86_64", configuration, ReportSettings.HTML.name, Path("path"))
|
||||
Report.load("x86_64", configuration, ReportSettings.HTML.name).run(Path("path"))
|
||||
report_mock.assert_called_once()
|
||||
|
@ -7,6 +7,22 @@ from ahriman.models.build_status import BuildStatusEnum
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
def test_load_dummy_client(configuration: Configuration) -> None:
|
||||
"""
|
||||
must load dummy client if no settings set
|
||||
"""
|
||||
assert isinstance(Client.load(configuration), Client)
|
||||
|
||||
|
||||
def test_load_full_client(configuration: Configuration) -> None:
|
||||
"""
|
||||
must load full client if no settings set
|
||||
"""
|
||||
configuration.set("web", "host", "localhost")
|
||||
configuration.set("web", "port", "8080")
|
||||
assert isinstance(Client.load(configuration), WebClient)
|
||||
|
||||
|
||||
def test_add(client: Client, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must process package addition without errors
|
||||
@ -98,19 +114,3 @@ def test_set_unknown(client: Client, package_ahriman: Package, mocker: MockerFix
|
||||
client.set_unknown(package_ahriman)
|
||||
|
||||
add_mock.assert_called_with(package_ahriman, BuildStatusEnum.Unknown)
|
||||
|
||||
|
||||
def test_load_dummy_client(configuration: Configuration) -> None:
|
||||
"""
|
||||
must load dummy client if no settings set
|
||||
"""
|
||||
assert isinstance(Client.load(configuration), Client)
|
||||
|
||||
|
||||
def test_load_full_client(configuration: Configuration) -> None:
|
||||
"""
|
||||
must load full client if no settings set
|
||||
"""
|
||||
configuration.set("web", "host", "localhost")
|
||||
configuration.set("web", "port", "8080")
|
||||
assert isinstance(Client.load(configuration), WebClient)
|
||||
|
@ -14,8 +14,8 @@ def test_from_path(mocker: MockerFixture) -> None:
|
||||
load_logging_mock = mocker.patch("ahriman.core.configuration.Configuration.load_logging")
|
||||
path = Path("path")
|
||||
|
||||
config = Configuration.from_path(path, "x86_64", True)
|
||||
assert config.path == path
|
||||
configuration = Configuration.from_path(path, "x86_64", True)
|
||||
assert configuration.path == path
|
||||
read_mock.assert_called_with(path)
|
||||
load_includes_mock.assert_called_once()
|
||||
load_logging_mock.assert_called_once()
|
||||
|
@ -15,7 +15,7 @@ def test_upload_failure(configuration: Configuration, mocker: MockerFixture) ->
|
||||
"""
|
||||
mocker.patch("ahriman.core.upload.rsync.Rsync.sync", side_effect=Exception())
|
||||
with pytest.raises(SyncFailed):
|
||||
Upload.run("x86_64", configuration, UploadSettings.Rsync.name, Path("path"))
|
||||
Upload.load("x86_64", configuration, UploadSettings.Rsync.name).run(Path("path"))
|
||||
|
||||
|
||||
def test_upload_rsync(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
@ -23,7 +23,7 @@ def test_upload_rsync(configuration: Configuration, mocker: MockerFixture) -> No
|
||||
must upload via rsync
|
||||
"""
|
||||
upload_mock = mocker.patch("ahriman.core.upload.rsync.Rsync.sync")
|
||||
Upload.run("x86_64", configuration, UploadSettings.Rsync.name, Path("path"))
|
||||
Upload.load("x86_64", configuration, UploadSettings.Rsync.name).run(Path("path"))
|
||||
upload_mock.assert_called_once()
|
||||
|
||||
|
||||
@ -32,5 +32,5 @@ def test_upload_s3(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
must upload via s3
|
||||
"""
|
||||
upload_mock = mocker.patch("ahriman.core.upload.s3.S3.sync")
|
||||
Upload.run("x86_64", configuration, UploadSettings.S3.name, Path("path"))
|
||||
Upload.load("x86_64", configuration, UploadSettings.S3.name).run(Path("path"))
|
||||
upload_mock.assert_called_once()
|
Reference in New Issue
Block a user