debian-koji/tests/test_lib/test_check_sigmd5.py
2020-10-06 15:00:23 +02:00

32 lines
888 B
Python

# coding=utf-8
from __future__ import absolute_import
import os.path
import shutil
import tempfile
import unittest
from koji.util import check_sigmd5
class TestCheckSigMD5(unittest.TestCase):
def setUp(self):
self.tempdir = tempfile.mkdtemp()
orig_path = os.path.join(os.path.dirname(__file__), 'data/rpms/test-deps-1-1.fc24.x86_64.rpm')
self.path = '%s/test.rpm' % self.tempdir
shutil.copyfile(orig_path, self.path)
def tearDown(self):
shutil.rmtree(self.tempdir)
def test_check_sigmd5_good(self):
value = check_sigmd5(self.path)
self.assertEqual(value, True)
def test_check_sigmd5_bad(self):
# corrupt the file by truncating it
with open(self.path, 'a+b') as f:
f.seek(5, 2)
f.truncate()
value = check_sigmd5(self.path)
self.assertEqual(value, False)