From f97e9258aad0364071ff9bd631ff98e7ba31ad08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 14 Sep 2016 10:18:01 +0200 Subject: [PATCH] checksums: Never skip checksumming phase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It does not make sense for this phase to be skipped. If there are any images, we need to generate the checksums so that writing metadata works. If there are no images, the phase does not do anything and is therefore very fast. Signed-off-by: Lubomír Sedlář --- pungi/phases/image_checksum.py | 7 +++++++ tests/test_imagechecksumphase.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/pungi/phases/image_checksum.py b/pungi/phases/image_checksum.py index fb7f59d6..ad0b9ec5 100644 --- a/pungi/phases/image_checksum.py +++ b/pungi/phases/image_checksum.py @@ -25,6 +25,13 @@ class ImageChecksumPhase(PhaseBase): self.checksums = self.compose.conf['media_checksums'] self.one_file = self.compose.conf['media_checksum_one_file'] + def skip(self): + # Skipping this phase does not make sense: + # * if there are no images, it doesn't do anything and is quick + # * if there are images, they must have checksums computed or else + # writing metadata will fail + return False + def validate(self): errors = [] try: diff --git a/tests/test_imagechecksumphase.py b/tests/test_imagechecksumphase.py index 5c5abc2a..d3faa008 100755 --- a/tests/test_imagechecksumphase.py +++ b/tests/test_imagechecksumphase.py @@ -20,6 +20,11 @@ from tests.helpers import DummyCompose, PungiTestCase class TestImageChecksumPhase(PungiTestCase): + def test_phase_is_never_skipped(self): + compose = DummyCompose(self.topdir, {}) + phase = ImageChecksumPhase(compose) + self.assertFalse(phase.skip()) + def test_config_skip_individual_with_multiple_algorithms(self): compose = DummyCompose(self.topdir, { 'media_checksums': ['md5', 'sha1'],