debian-koji/tests/test_hub/test_import_archive_internal.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

23 lines
795 B
Python

import unittest
from unittest import mock
import koji
import kojihub
class TestImportArchiveInternal(unittest.TestCase):
def setUp(self):
self.os_path_exists = mock.patch('os.path.exists').start()
def tearDown(self):
mock.patch.stopall()
def test_import_archive_internal_non_exist_filepath(self):
self.os_path_exists.return_value = False
filepath = 'test/file/path/to/archive'
buildinfo = {'id': 1, 'name': 'test-build'}
type_archive = 'maven'
typeInfo = {'group_id': 1, 'artifact_id': 2, 'version': 3}
with self.assertRaises(koji.GenericError) as cm:
kojihub.import_archive_internal(filepath, buildinfo, type_archive, typeInfo)
self.assertEqual(f"No such file: {filepath}", str(cm.exception))