mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
add notes about documentation and methods inside class
Because I always forget which way I used before
This commit is contained in:
@ -11,22 +11,6 @@ from ahriman.models.package_source import PackageSource
|
||||
from ahriman.models.result import Result
|
||||
|
||||
|
||||
def test_on_result(application_packages: ApplicationPackages) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing finalize method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
application_packages.on_result(Result())
|
||||
|
||||
|
||||
def test_known_packages(application_packages: ApplicationPackages) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing known_packages method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
application_packages._known_packages()
|
||||
|
||||
|
||||
def test_add_archive(
|
||||
application_packages: ApplicationPackages,
|
||||
package_ahriman: Package,
|
||||
@ -129,6 +113,14 @@ def test_add_repository(application_packages: ApplicationPackages, package_ahrim
|
||||
update_remote_mock.assert_called_once_with(package_ahriman)
|
||||
|
||||
|
||||
def test_known_packages(application_packages: ApplicationPackages) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing known_packages method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
application_packages._known_packages()
|
||||
|
||||
|
||||
def test_process_dependencies(application_packages: ApplicationPackages, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process dependencies addition
|
||||
@ -237,6 +229,14 @@ def test_add_add_remote(application_packages: ApplicationPackages, package_descr
|
||||
add_mock.assert_called_once_with(url, set(), False)
|
||||
|
||||
|
||||
def test_on_result(application_packages: ApplicationPackages) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing finalize method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
application_packages.on_result(Result())
|
||||
|
||||
|
||||
def test_remove(application_packages: ApplicationPackages, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must remove package
|
||||
|
@ -9,14 +9,6 @@ from ahriman.models.package import Package
|
||||
from ahriman.models.result import Result
|
||||
|
||||
|
||||
def test_on_result(application_repository: ApplicationRepository) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing finalize method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
application_repository.on_result(Result())
|
||||
|
||||
|
||||
def test_clean_cache(application_repository: ApplicationRepository, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must clean cache directory
|
||||
@ -62,6 +54,14 @@ def test_clean_pacman(application_repository: ApplicationRepository, mocker: Moc
|
||||
clear_mock.assert_called_once_with()
|
||||
|
||||
|
||||
def test_on_result(application_repository: ApplicationRepository) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing finalize method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
application_repository.on_result(Result())
|
||||
|
||||
|
||||
def test_sign(application_repository: ApplicationRepository, package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
|
@ -12,40 +12,6 @@ from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.internal_status import InternalStatus
|
||||
|
||||
|
||||
def test_enter(lock: Lock, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process with context manager
|
||||
"""
|
||||
check_user_mock = mocker.patch("ahriman.application.lock.Lock.check_user")
|
||||
check_version_mock = mocker.patch("ahriman.application.lock.Lock.check_version")
|
||||
clear_mock = mocker.patch("ahriman.application.lock.Lock.clear")
|
||||
create_mock = mocker.patch("ahriman.application.lock.Lock.create")
|
||||
update_status_mock = mocker.patch("ahriman.core.status.client.Client.update_self")
|
||||
|
||||
with lock:
|
||||
pass
|
||||
check_user_mock.assert_called_once_with()
|
||||
clear_mock.assert_called_once_with()
|
||||
create_mock.assert_called_once_with()
|
||||
check_version_mock.assert_called_once_with()
|
||||
update_status_mock.assert_has_calls([MockCall(BuildStatusEnum.Building), MockCall(BuildStatusEnum.Success)])
|
||||
|
||||
|
||||
def test_exit_with_exception(lock: Lock, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process with context manager in case if exception raised
|
||||
"""
|
||||
mocker.patch("ahriman.application.lock.Lock.check_user")
|
||||
mocker.patch("ahriman.application.lock.Lock.clear")
|
||||
mocker.patch("ahriman.application.lock.Lock.create")
|
||||
update_status_mock = mocker.patch("ahriman.core.status.client.Client.update_self")
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with lock:
|
||||
raise Exception()
|
||||
update_status_mock.assert_has_calls([MockCall(BuildStatusEnum.Building), MockCall(BuildStatusEnum.Failed)])
|
||||
|
||||
|
||||
def test_check_version(lock: Lock, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must check version correctly
|
||||
@ -166,3 +132,37 @@ def test_create_unsafe(lock: Lock) -> None:
|
||||
|
||||
lock.create()
|
||||
lock.path.unlink()
|
||||
|
||||
|
||||
def test_enter(lock: Lock, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process with context manager
|
||||
"""
|
||||
check_user_mock = mocker.patch("ahriman.application.lock.Lock.check_user")
|
||||
check_version_mock = mocker.patch("ahriman.application.lock.Lock.check_version")
|
||||
clear_mock = mocker.patch("ahriman.application.lock.Lock.clear")
|
||||
create_mock = mocker.patch("ahriman.application.lock.Lock.create")
|
||||
update_status_mock = mocker.patch("ahriman.core.status.client.Client.update_self")
|
||||
|
||||
with lock:
|
||||
pass
|
||||
check_user_mock.assert_called_once_with()
|
||||
clear_mock.assert_called_once_with()
|
||||
create_mock.assert_called_once_with()
|
||||
check_version_mock.assert_called_once_with()
|
||||
update_status_mock.assert_has_calls([MockCall(BuildStatusEnum.Building), MockCall(BuildStatusEnum.Success)])
|
||||
|
||||
|
||||
def test_exit_with_exception(lock: Lock, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process with context manager in case if exception raised
|
||||
"""
|
||||
mocker.patch("ahriman.application.lock.Lock.check_user")
|
||||
mocker.patch("ahriman.application.lock.Lock.clear")
|
||||
mocker.patch("ahriman.application.lock.Lock.create")
|
||||
update_status_mock = mocker.patch("ahriman.core.status.client.Client.update_self")
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with lock:
|
||||
raise Exception()
|
||||
update_status_mock.assert_has_calls([MockCall(BuildStatusEnum.Building), MockCall(BuildStatusEnum.Failed)])
|
||||
|
@ -8,22 +8,6 @@ from ahriman.core.database import SQLite
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
def test_logger(database: SQLite) -> None:
|
||||
"""
|
||||
must set logger attribute
|
||||
"""
|
||||
assert database.logger
|
||||
assert database.logger.name == "ahriman.core.database.sqlite.SQLite"
|
||||
|
||||
|
||||
def test_logger_attribute_error(database: SQLite) -> None:
|
||||
"""
|
||||
must raise AttributeError in case if no attribute found
|
||||
"""
|
||||
with pytest.raises(AttributeError):
|
||||
database.loggerrrr
|
||||
|
||||
|
||||
def test_logger_name(database: SQLite, repo: Repo) -> None:
|
||||
"""
|
||||
must correctly generate logger name
|
||||
@ -74,3 +58,19 @@ def test_in_package_context_failed(database: SQLite, package_ahriman: Package, m
|
||||
raise Exception()
|
||||
|
||||
reset_mock.assert_called_once_with()
|
||||
|
||||
|
||||
def test_logger(database: SQLite) -> None:
|
||||
"""
|
||||
must set logger attribute
|
||||
"""
|
||||
assert database.logger
|
||||
assert database.logger.name == "ahriman.core.database.sqlite.SQLite"
|
||||
|
||||
|
||||
def test_logger_attribute_error(database: SQLite) -> None:
|
||||
"""
|
||||
must raise AttributeError in case if no attribute found
|
||||
"""
|
||||
with pytest.raises(AttributeError):
|
||||
database.loggerrrr
|
||||
|
@ -30,14 +30,6 @@ def _mock_clear_check() -> None:
|
||||
])
|
||||
|
||||
|
||||
def test_packages_built(cleaner: Cleaner) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
cleaner.packages_built()
|
||||
|
||||
|
||||
def test_clear_cache(cleaner: Cleaner, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must remove every cached sources
|
||||
@ -84,3 +76,11 @@ def test_clear_queue(cleaner: Cleaner, mocker: MockerFixture) -> None:
|
||||
clear_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_clear")
|
||||
cleaner.clear_queue()
|
||||
clear_mock.assert_called_once_with(None)
|
||||
|
||||
|
||||
def test_packages_built(cleaner: Cleaner) -> None:
|
||||
"""
|
||||
must raise NotImplemented for missing method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
cleaner.packages_built()
|
||||
|
Reference in New Issue
Block a user