add docker support (#52)

* add docker support

* make shellcheck happy
This commit is contained in:
2022-03-13 23:43:25 +03:00
committed by GitHub
parent 9f4acacada
commit 61efbb71a2
59 changed files with 429 additions and 103 deletions

View File

@ -19,7 +19,7 @@ def cleaner(configuration: Configuration, mocker: MockerFixture) -> Cleaner:
:return: cleaner test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Cleaner("x86_64", configuration, no_report=True)
return Cleaner("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -36,7 +36,7 @@ def executor(configuration: Configuration, mocker: MockerFixture) -> Executor:
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_manual")
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Executor("x86_64", configuration, no_report=True)
return Executor("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -48,7 +48,7 @@ def repository(configuration: Configuration, mocker: MockerFixture) -> Repositor
:return: repository test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Repository("x86_64", configuration, no_report=True)
return Repository("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -58,7 +58,7 @@ def properties(configuration: Configuration) -> Properties:
:param configuration: configuration fixture
:return: properties test instance
"""
return Properties("x86_64", configuration, no_report=True)
return Properties("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -75,4 +75,4 @@ def update_handler(configuration: Configuration, mocker: MockerFixture) -> Updat
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_manual")
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return UpdateHandler("x86_64", configuration, no_report=True)
return UpdateHandler("x86_64", configuration, no_report=True, unsafe=False)

View File

@ -12,7 +12,7 @@ def test_create_tree_on_load(configuration: Configuration, mocker: MockerFixture
"""
mocker.patch("ahriman.core.repository.properties.check_user")
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
Properties("x86_64", configuration, True)
Properties("x86_64", configuration, True, False)
tree_create_mock.assert_called_once_with()
@ -23,7 +23,7 @@ def test_create_tree_on_load_unsafe(configuration: Configuration, mocker: Mocker
"""
mocker.patch("ahriman.core.repository.properties.check_user", side_effect=UnsafeRun(0, 1))
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
Properties("x86_64", configuration, True)
Properties("x86_64", configuration, True, False)
tree_create_mock.assert_not_called()
@ -34,7 +34,7 @@ def test_create_dummy_report_client(configuration: Configuration, mocker: Mocker
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
load_mock = mocker.patch("ahriman.core.status.client.Client.load")
properties = Properties("x86_64", configuration, True)
properties = Properties("x86_64", configuration, True, False)
load_mock.assert_not_called()
assert not isinstance(properties.reporter, WebClient)
@ -46,6 +46,6 @@ def test_create_full_report_client(configuration: Configuration, mocker: MockerF
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
load_mock = mocker.patch("ahriman.core.status.client.Client.load")
Properties("x86_64", configuration, False)
Properties("x86_64", configuration, False, False)
load_mock.assert_called_once_with(configuration)

View File

@ -58,7 +58,7 @@ def test_check_user(mocker: MockerFixture) -> None:
"""
cwd = Path.cwd()
mocker.patch("os.getuid", return_value=cwd.stat().st_uid)
check_user(cwd)
check_user(cwd, False)
def test_check_user_no_directory(mocker: MockerFixture) -> None:
@ -66,7 +66,7 @@ def test_check_user_no_directory(mocker: MockerFixture) -> None:
must not fail in case if no directory found
"""
mocker.patch("pathlib.Path.exists", return_value=False)
check_user(Path.cwd())
check_user(Path.cwd(), False)
def test_check_user_exception(mocker: MockerFixture) -> None:
@ -77,7 +77,16 @@ def test_check_user_exception(mocker: MockerFixture) -> None:
mocker.patch("os.getuid", return_value=cwd.stat().st_uid + 1)
with pytest.raises(UnsafeRun):
check_user(cwd)
check_user(cwd, False)
def test_check_unsafe(mocker: MockerFixture) -> None:
"""
must skip check if unsafe flag is set
"""
cwd = Path.cwd()
mocker.patch("os.getuid", return_value=cwd.stat().st_uid + 1)
check_user(cwd, True)
def test_filter_json(package_ahriman: Package) -> None: