Fix Makefile for RHEL7
This commit is contained in:
parent
92a773a19d
commit
3999667a8c
5 changed files with 36 additions and 50 deletions
|
|
@ -1,14 +1,14 @@
|
|||
PYVER_MAJOR := $(shell $(PYTHON) -c 'import sys; print(".".join(sys.version.split(".")[:1]))')
|
||||
PACKAGE = $(shell basename `pwd`)
|
||||
PYFILES = $(wildcard *.py)
|
||||
PYFILES_ALL = $(wildcard *.py)
|
||||
PYSCRIPTS =
|
||||
SUBDIRS =
|
||||
PKGDIR = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")/$(PACKAGE)
|
||||
|
||||
ifeq ($(PYVER_MAJOR),2)
|
||||
PYFILES=$(filter-out db.py,$(PYFILES))
|
||||
PYFILES=$(filter-out db.py,$(PYFILES_ALL))
|
||||
else
|
||||
PYFILES=$(PYFILES)
|
||||
PYFILES=$(PYFILES_ALL)
|
||||
endif
|
||||
|
||||
_default:
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class TestImportBuild(unittest.TestCase):
|
|||
self.check_volume_policy = mock.patch('kojihub.check_volume_policy').start()
|
||||
self.new_typed_build = mock.patch('kojihub.new_typed_build').start()
|
||||
self._dml = mock.patch('koji.db._dml').start()
|
||||
self._singleValue = mock.patch('kojihub._singleValue').start()
|
||||
self.nextval = mock.patch('kojihub.nextval').start()
|
||||
self.get_build = mock.patch('kojihub.get_build').start()
|
||||
self.add_rpm_sig = mock.patch('kojihub.add_rpm_sig').start()
|
||||
self.rip_rpm_sighdr = mock.patch('koji.rip_rpm_sighdr').start()
|
||||
|
|
|
|||
|
|
@ -6,9 +6,17 @@ import shutil
|
|||
import tempfile
|
||||
import copy
|
||||
|
||||
IP = kojihub.InsertProcessor
|
||||
|
||||
|
||||
class TestImportRPM(unittest.TestCase):
|
||||
|
||||
def getInsert(self, *args, **kwargs):
|
||||
insert = IP(*args, **kwargs)
|
||||
insert.execute = mock.MagicMock()
|
||||
self.inserts.append(insert)
|
||||
return insert
|
||||
|
||||
def setUp(self):
|
||||
self.exports = kojihub.RootExports()
|
||||
self.tempdir = tempfile.mkdtemp()
|
||||
|
|
@ -41,10 +49,12 @@ class TestImportRPM(unittest.TestCase):
|
|||
self.get_build = mock.patch('kojihub.get_build').start()
|
||||
self.get_rpm_header = mock.patch('koji.get_rpm_header').start()
|
||||
self.new_typed_build = mock.patch('kojihub.new_typed_build').start()
|
||||
self._dml = mock.patch('koji.db._dml').start()
|
||||
self._singleValue = mock.patch('kojihub._singleValue').start()
|
||||
self.nextval = mock.patch('kojihub.nextval').start()
|
||||
self.os_path_exists = mock.patch('os.path.exists').start()
|
||||
self.os_path_basename = mock.patch('os.path.basename').start()
|
||||
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
|
||||
side_effect=self.getInsert).start()
|
||||
self.inserts = []
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tempdir)
|
||||
|
|
@ -64,6 +74,7 @@ class TestImportRPM(unittest.TestCase):
|
|||
}
|
||||
with self.assertRaises(koji.GenericError):
|
||||
kojihub.import_rpm(self.filename)
|
||||
self.assertEqual(len(self.inserts), 0)
|
||||
|
||||
def test_import_rpm_completed_build(self):
|
||||
self.os_path_basename.return_value = 'name-version-release.arch.rpm'
|
||||
|
|
@ -75,27 +86,10 @@ class TestImportRPM(unittest.TestCase):
|
|||
'release': 'release',
|
||||
'id': 12345,
|
||||
}
|
||||
self._singleValue.return_value = 9876
|
||||
self.nextval.return_value = 9876
|
||||
kojihub.import_rpm(self.filename)
|
||||
fields = [
|
||||
'arch',
|
||||
'build_id',
|
||||
'buildroot_id',
|
||||
'buildtime',
|
||||
'epoch',
|
||||
'external_repo_id',
|
||||
'id',
|
||||
'name',
|
||||
'payloadhash',
|
||||
'release',
|
||||
'size',
|
||||
'version',
|
||||
]
|
||||
statement = 'INSERT INTO rpminfo (%s) VALUES (%s)' % (
|
||||
", ".join(fields),
|
||||
", ".join(['%%(%s)s' % field for field in fields])
|
||||
)
|
||||
values = {
|
||||
|
||||
data = {
|
||||
'build_id': 12345,
|
||||
'name': 'name',
|
||||
'arch': 'arch',
|
||||
|
|
@ -109,7 +103,11 @@ class TestImportRPM(unittest.TestCase):
|
|||
'id': 9876,
|
||||
'size': 0,
|
||||
}
|
||||
self._dml.assert_called_once_with(statement, values)
|
||||
self.assertEqual(len(self.inserts), 1)
|
||||
insert = self.inserts[0]
|
||||
self.assertEqual(insert.table, 'rpminfo')
|
||||
self.assertEqual(insert.data, data)
|
||||
self.assertEqual(insert.rawdata, {})
|
||||
|
||||
def test_import_rpm_completed_source_build(self):
|
||||
self.os_path_basename.return_value = 'name-version-release.src.rpm'
|
||||
|
|
@ -128,27 +126,9 @@ class TestImportRPM(unittest.TestCase):
|
|||
'release': 'release',
|
||||
'id': 12345,
|
||||
}
|
||||
self._singleValue.return_value = 9876
|
||||
self.nextval.return_value = 9876
|
||||
kojihub.import_rpm(self.src_filename)
|
||||
fields = [
|
||||
'arch',
|
||||
'build_id',
|
||||
'buildroot_id',
|
||||
'buildtime',
|
||||
'epoch',
|
||||
'external_repo_id',
|
||||
'id',
|
||||
'name',
|
||||
'payloadhash',
|
||||
'release',
|
||||
'size',
|
||||
'version',
|
||||
]
|
||||
statement = 'INSERT INTO rpminfo (%s) VALUES (%s)' % (
|
||||
", ".join(fields),
|
||||
", ".join(['%%(%s)s' % field for field in fields])
|
||||
)
|
||||
values = {
|
||||
data = {
|
||||
'build_id': 12345,
|
||||
'name': 'name',
|
||||
'arch': 'src',
|
||||
|
|
@ -162,7 +142,11 @@ class TestImportRPM(unittest.TestCase):
|
|||
'id': 9876,
|
||||
'size': 0,
|
||||
}
|
||||
self._dml.assert_called_once_with(statement, values)
|
||||
self.assertEqual(len(self.inserts), 1)
|
||||
insert = self.inserts[0]
|
||||
self.assertEqual(insert.table, 'rpminfo')
|
||||
self.assertEqual(insert.data, data)
|
||||
self.assertEqual(insert.rawdata, {})
|
||||
|
||||
def test_non_exist_file(self):
|
||||
basename = 'rpm-1-34'
|
||||
|
|
@ -170,6 +154,7 @@ class TestImportRPM(unittest.TestCase):
|
|||
with self.assertRaises(koji.GenericError) as cm:
|
||||
kojihub.import_rpm(self.filename, basename)
|
||||
self.assertEqual(f"No such file: {self.filename}", str(cm.exception))
|
||||
self.assertEqual(len(self.inserts), 0)
|
||||
|
||||
def test_non_exist_build(self):
|
||||
self.cursor.fetchone.return_value = None
|
||||
|
|
@ -186,3 +171,4 @@ class TestImportRPM(unittest.TestCase):
|
|||
with self.assertRaises(koji.GenericError) as cm:
|
||||
kojihub.import_rpm(self.src_filename)
|
||||
self.assertEqual("No such build", str(cm.exception))
|
||||
self.assertEqual(len(self.inserts), 0)
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class TestQueryProcessor(unittest.TestCase):
|
|||
result = next(generator)
|
||||
self.assertEqual(result, {'something': 'value number 3'})
|
||||
|
||||
@mock.patch('kojihub._multiRow')
|
||||
@mock.patch('koji.db._multiRow')
|
||||
def test_execution_as_list_transform(self, multirow):
|
||||
multirow.return_value = [{'col1': 'result_1_col_1', 'col2': 'result_1_col_2'},
|
||||
{'col1': 'result_2_col_1', 'col2': 'result_2_col_2'}]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from koji.context import context
|
|||
|
||||
import koji
|
||||
import koji.db
|
||||
from koji.db import QueryProcessor, InsertProcessor, BulkInsertProcessor
|
||||
from koji.db import QueryProcessor, BulkInsertProcessor
|
||||
|
||||
|
||||
def clean_sessions(cursor, vacuum, test, age):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue