do not trigger update on sign command

This commit is contained in:
Evgenii Alekseev 2022-12-01 11:15:15 +02:00
parent ebd06cb443
commit a4f646eb2a
2 changed files with 9 additions and 19 deletions

View File

@ -17,8 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import shutil
from pathlib import Path
from typing import Callable, Iterable, List
@ -85,13 +83,10 @@ class ApplicationRepository(ApplicationProperties):
if archive.filepath is None:
self.logger.warning("filepath is empty for %s", package.base)
continue # avoid mypy warning
src = self.repository.paths.repository / archive.filepath
dst = self.repository.paths.packages / archive.filepath
shutil.copy(src, dst)
# run generic update function
self.update([])
self.repository.sign.process_sign_package(archive.filepath, package.base)
# sign repository database if set
self.repository.sign.process_sign_repository(self.repository.repo.repo_path)
# process triggers
self.on_result(Result())
def unknown(self) -> List[str]:

View File

@ -69,18 +69,17 @@ def test_sign(application_repository: ApplicationRepository, package_ahriman: Pa
"""
mocker.patch("ahriman.core.repository.repository.Repository.packages",
return_value=[package_ahriman, package_python_schedule])
copy_mock = mocker.patch("shutil.copy")
update_mock = mocker.patch("ahriman.application.application.application_repository.ApplicationRepository.update")
sign_package_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_package")
sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_repository")
on_result_mock = mocker.patch(
"ahriman.application.application.application_repository.ApplicationRepository.on_result")
application_repository.sign([])
copy_mock.assert_has_calls([
MockCall(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int)),
MockCall(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int))
sign_package_mock.assert_has_calls([
MockCall(pytest.helpers.anyvar(int), package_ahriman.base),
MockCall(pytest.helpers.anyvar(int), package_python_schedule.base),
MockCall(pytest.helpers.anyvar(int), package_python_schedule.base),
])
update_mock.assert_called_once_with([])
sign_repository_mock.assert_called_once_with(application_repository.repository.repo.repo_path)
on_result_mock.assert_called_once_with(Result())
@ -105,18 +104,14 @@ def test_sign_specific(application_repository: ApplicationRepository, package_ah
"""
mocker.patch("ahriman.core.repository.repository.Repository.packages",
return_value=[package_ahriman, package_python_schedule])
copy_mock = mocker.patch("shutil.copy")
update_mock = mocker.patch("ahriman.application.application.application_repository.ApplicationRepository.update")
sign_package_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_package")
sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_repository")
on_result_mock = mocker.patch(
"ahriman.application.application.application_repository.ApplicationRepository.on_result")
filename = package_ahriman.packages[package_ahriman.base].filepath
application_repository.sign([package_ahriman.base])
copy_mock.assert_called_once_with(
application_repository.repository.paths.repository / filename.name,
application_repository.repository.paths.packages / filename.name)
update_mock.assert_called_once_with([])
sign_package_mock.assert_called_once_with(filename, package_ahriman.base)
sign_repository_mock.assert_called_once_with(application_repository.repository.repo.repo_path)
on_result_mock.assert_called_once_with(Result())