debian-koji/tests/test_hub/test_write_signed_rpm.py
Yuming Zhu ca05418fb5 unittest: use unittest.mock instead of mock
because the absence of unittest.mock on python2.7, we still fallback to
mock
2024-10-23 16:35:30 +00:00

24 lines
817 B
Python

import unittest
from unittest import mock
import koji
import kojihub
class TestWriteSignedRPM(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.kojihub.context').start()
self.get_rpm = mock.patch('kojihub.kojihub.get_rpm').start()
def tearDown(self):
mock.patch.stopall()
def test_write_signed_rpm_not_internal_rpm(self):
sigkey = 'test-sigkey'
rpm_id = 1
rpminfo = {'external_repo_id': 1, 'external_repo_name': 'test-external-repo'}
self.get_rpm.return_value = rpminfo
with self.assertRaises(koji.GenericError) as cm:
kojihub.write_signed_rpm(rpm_id, sigkey)
self.assertEqual(f"Not an internal rpm: {rpm_id} (from {rpminfo['external_repo_name']})",
str(cm.exception))