do not trigger update on sign command

This commit is contained in:
Evgenii Alekseev 2022-12-01 11:15:15 +02:00
parent 01eda513cf
commit 7aa91f9e2e
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 # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import shutil
from pathlib import Path from pathlib import Path
from typing import Callable, Iterable, List from typing import Callable, Iterable, List
@ -85,13 +83,10 @@ class ApplicationRepository(ApplicationProperties):
if archive.filepath is None: if archive.filepath is None:
self.logger.warning("filepath is empty for %s", package.base) self.logger.warning("filepath is empty for %s", package.base)
continue # avoid mypy warning continue # avoid mypy warning
src = self.repository.paths.repository / archive.filepath self.repository.sign.process_sign_package(archive.filepath, package.base)
dst = self.repository.paths.packages / archive.filepath
shutil.copy(src, dst)
# run generic update function
self.update([])
# sign repository database if set # sign repository database if set
self.repository.sign.process_sign_repository(self.repository.repo.repo_path) self.repository.sign.process_sign_repository(self.repository.repo.repo_path)
# process triggers
self.on_result(Result()) self.on_result(Result())
def unknown(self) -> List[str]: 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", mocker.patch("ahriman.core.repository.repository.Repository.packages",
return_value=[package_ahriman, package_python_schedule]) return_value=[package_ahriman, package_python_schedule])
copy_mock = mocker.patch("shutil.copy") sign_package_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_package")
update_mock = mocker.patch("ahriman.application.application.application_repository.ApplicationRepository.update")
sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_repository") sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_repository")
on_result_mock = mocker.patch( on_result_mock = mocker.patch(
"ahriman.application.application.application_repository.ApplicationRepository.on_result") "ahriman.application.application.application_repository.ApplicationRepository.on_result")
application_repository.sign([]) application_repository.sign([])
copy_mock.assert_has_calls([ sign_package_mock.assert_has_calls([
MockCall(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int)), MockCall(pytest.helpers.anyvar(int), package_ahriman.base),
MockCall(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int)) 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) sign_repository_mock.assert_called_once_with(application_repository.repository.repo.repo_path)
on_result_mock.assert_called_once_with(Result()) 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", mocker.patch("ahriman.core.repository.repository.Repository.packages",
return_value=[package_ahriman, package_python_schedule]) return_value=[package_ahriman, package_python_schedule])
copy_mock = mocker.patch("shutil.copy") sign_package_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_package")
update_mock = mocker.patch("ahriman.application.application.application_repository.ApplicationRepository.update")
sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_repository") sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_repository")
on_result_mock = mocker.patch( on_result_mock = mocker.patch(
"ahriman.application.application.application_repository.ApplicationRepository.on_result") "ahriman.application.application.application_repository.ApplicationRepository.on_result")
filename = package_ahriman.packages[package_ahriman.base].filepath filename = package_ahriman.packages[package_ahriman.base].filepath
application_repository.sign([package_ahriman.base]) application_repository.sign([package_ahriman.base])
copy_mock.assert_called_once_with( sign_package_mock.assert_called_once_with(filename, package_ahriman.base)
application_repository.repository.paths.repository / filename.name,
application_repository.repository.paths.packages / filename.name)
update_mock.assert_called_once_with([])
sign_repository_mock.assert_called_once_with(application_repository.repository.repo.repo_path) sign_repository_mock.assert_called_once_with(application_repository.repository.repo.repo_path)
on_result_mock.assert_called_once_with(Result()) on_result_mock.assert_called_once_with(Result())