mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-15 06:55:48 +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:
36
tests/ahriman/core/upload/test_upload.py
Normal file
36
tests/ahriman/core/upload/test_upload.py
Normal file
@ -0,0 +1,36 @@
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import SyncFailed
|
||||
from ahriman.core.upload.upload import Upload
|
||||
from ahriman.models.upload_settings import UploadSettings
|
||||
|
||||
|
||||
def test_upload_failure(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise SyncFailed on errors
|
||||
"""
|
||||
mocker.patch("ahriman.core.upload.rsync.Rsync.sync", side_effect=Exception())
|
||||
with pytest.raises(SyncFailed):
|
||||
Upload.load("x86_64", configuration, UploadSettings.Rsync.name).run(Path("path"))
|
||||
|
||||
|
||||
def test_upload_rsync(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must upload via rsync
|
||||
"""
|
||||
upload_mock = mocker.patch("ahriman.core.upload.rsync.Rsync.sync")
|
||||
Upload.load("x86_64", configuration, UploadSettings.Rsync.name).run(Path("path"))
|
||||
upload_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_upload_s3(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must upload via s3
|
||||
"""
|
||||
upload_mock = mocker.patch("ahriman.core.upload.s3.S3.sync")
|
||||
Upload.load("x86_64", configuration, UploadSettings.S3.name).run(Path("path"))
|
||||
upload_mock.assert_called_once()
|
Reference in New Issue
Block a user