add a unit test
This commit is contained in:
parent
4191840bd7
commit
c60ec3c2f3
1 changed files with 35 additions and 0 deletions
35
tests/test_lib/test_check_sigmd5.py
Normal file
35
tests/test_lib/test_check_sigmd5.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
import os.path
|
||||
import shutil
|
||||
import tempfile
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue