PR#3588: Move hub code to site-packages

Merges #3588
https://pagure.io/koji/pull-request/3588

Fixes: #3587
https://pagure.io/koji/issue/3587
Move hub code to site-packages
This commit is contained in:
Tomas Kopecek 2022-12-08 13:39:05 +01:00
commit 463e469b80
157 changed files with 810 additions and 766 deletions

View file

@ -1,11 +1,18 @@
NAME=koji
SPECFILE = $(firstword $(wildcard *.spec))
SUBDIRS = hub builder koji cli util www plugins vm
ifndef PYTHON
export PYTHON=python2
endif
PYVER_MAJOR := $(shell $(PYTHON) -c 'import sys; print(".".join(sys.version.split(".")[:1]))')
ifeq ($(PYVER_MAJOR),2)
SUBDIRS = builder koji cli plugins vm
else
SUBDIRS = kojihub builder koji cli util www plugins vm
endif
ifdef DIST
DIST_DEFINES := --define "dist $(DIST)"
endif

View file

@ -12,7 +12,7 @@ import sys
from urllib.parse import quote
sys.path.insert(0, os.getcwd())
sys.path.insert(1, os.path.join(os.getcwd(), 'hub'))
sys.path.insert(1, os.path.join(os.getcwd(), 'kojihub'))
import koji
import kojixmlrpc
import koji.xmlrpcplus

View file

View file

@ -335,9 +335,7 @@ Requires(postun): systemd
%description utils
Utilities for the Koji system
%endif
%if 0%{py3_support} > 1
%package web
Summary: Koji Web UI
Group: Applications/Internet
@ -405,7 +403,7 @@ make DESTDIR=$RPM_BUILD_ROOT KOJI_MINIMAL=1 PYTHON=%{__python2} install
popd
%endif
%if 0%{py2_support} > 1
for D in hub builder plugins util www vm ; do
for D in builder plugins vm ; do
pushd $D
make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python2} install
popd
@ -430,7 +428,7 @@ make DESTDIR=$RPM_BUILD_ROOT KOJI_MINIMAL=1 PYTHON=%{__python3} install
popd
%endif
%if 0%{py3_support} > 1
for D in hub builder plugins util www vm ; do
for D in kojihub builder plugins util www vm ; do
pushd $D
make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} install
popd
@ -549,6 +547,7 @@ rm -rf $RPM_BUILD_ROOT
%files -n python%{python3_pkgversion}-%{name}-hub
%{_datadir}/koji-hub/*.py
%{_datadir}/koji-hub/__pycache__
%{python3_sitelib}/kojihub
%files hub-plugins
%dir /etc/koji-hub/plugins

View file

@ -1,10 +1,9 @@
PYVER_MAJOR := $(shell $(PYTHON) -c 'import sys; print(".".join(sys.version.split(".")[:1]))')
PACKAGE = $(shell basename `pwd`)
PACKAGE = kojihub
PYFILES = $(wildcard *.py)
PKGDIR = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")/$(PACKAGE)
SERVERDIR = /usr/share/koji-hub
PYFILES = $(wildcard *.py)
_default:
@echo "nothing to make. try make install"
@ -20,18 +19,23 @@ install:
exit 1; \
fi
# python module
mkdir -p $(DESTDIR)/$(PKGDIR)
for p in $(PYFILES) ; do \
install -p -m 644 $$p $(DESTDIR)/$(PKGDIR)/$$p; \
done
$(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(PKGDIR)', 1, '$(PYDIR)', 1)"
# application files
mkdir -p $(DESTDIR)/etc/httpd/conf.d
install -p -m 644 httpd.conf $(DESTDIR)/etc/httpd/conf.d/kojihub.conf
install -p -m 644 app/httpd.conf $(DESTDIR)/etc/httpd/conf.d/kojihub.conf
mkdir -p $(DESTDIR)/etc/koji-hub
install -p -m 644 hub.conf $(DESTDIR)/etc/koji-hub/hub.conf
install -p -m 644 app/hub.conf $(DESTDIR)/etc/koji-hub/hub.conf
mkdir -p $(DESTDIR)/etc/koji-hub/hub.conf.d
mkdir -p $(DESTDIR)/$(SERVERDIR)
for p in $(PYFILES) ; do \
install -p -m 644 $$p $(DESTDIR)/$(SERVERDIR)/$$p; \
done
@if [ "$(PYVER_MAJOR)" == "3" ] ; then \
$(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(SERVERDIR)', 1, '$(PYDIR)', 1)" ; \
fi
mkdir -p $(DESTDIR)/$(SERVERDIR)
install -p -m 644 app/kojiapp.py $(DESTDIR)/$(SERVERDIR)/kojiapp.py
$(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(SERVERDIR)', 1, '$(PYDIR)', 1)"

48
kojihub/__init__.py Normal file
View file

@ -0,0 +1,48 @@
from .kojihub import * # noqa: F401 F403
# import also all private functions for backward compatibility
# new private methods should be imported via kojihub.kojihub
from .kojihub import ( # noqa: F401
_create_build_target,
_create_tag,
_delete_build,
_delete_build_target,
_delete_event_id,
_delete_tag,
_direct_pkglist_add,
_direct_pkglist_remove,
_direct_tag_build,
_direct_untag_build,
_edit_build_target,
_edit_tag,
_edit_user,
_fix_archive_row,
_fix_extra_field,
_fix_rpm_row,
_generate_maven_metadata,
_get_archive_type_by_id,
_get_archive_type_by_name,
_get_build_target,
_get_tarball_list,
_get_zipfile_list,
_grp_pkg_add,
_grp_pkg_remove,
_grp_pkg_unblock,
_grp_req_add,
_grp_req_remove,
_grp_req_unblock,
_grplist_add,
_grplist_remove,
_grplist_unblock,
_import_archive_file,
_import_wrapper,
_pkglist_add,
_pkglist_owner_add,
_pkglist_owner_remove,
_pkglist_remove,
_scan_sighdr,
_set_build_volume,
_tag_build,
_untag_build,
_writeInheritanceData,
_write_maven_repo_metadata,
)

View file

@ -2,7 +2,7 @@
# koji-hub is an xmlrpc interface to the Koji database
#
Alias /kojihub /usr/share/koji-hub/kojixmlrpc.py
Alias /kojihub /usr/share/koji-hub/kojiapp.py
<Directory "/usr/share/koji-hub">
Options ExecCGI

1
kojihub/app/kojiapp.py Normal file
View file

@ -0,0 +1 @@
from kojihub.kojixmlrpc import application # noqa: F401

View file

@ -7405,6 +7405,7 @@ def add_archive_type(name, description, extensions, compression_type=None):
:param str description: eg. "YAML Ain't Markup Language"
:param str extensions: space-separated list of descriptions, eg. "yaml yml"
"""
print(context)
context.session.assertPerm('admin')
verify_name_internal(name)
convert_value(description, cast=str, check_only=True)

View file

@ -36,6 +36,7 @@ import koji.db
import koji.plugin
import koji.policy
import koji.util
import kojihub
from koji.context import context
# import xmlrpclib functions from koji to use tweaked Marshaller
from koji.server import ServerError, BadRequest, RequestTimeout
@ -709,14 +710,6 @@ def setup_logging2(opts):
log_handler.setFormatter(HubFormatter(opts['LogFormat']))
def load_scripts(environ):
"""Update path and import our scripts files"""
global kojihub
scriptsdir = os.path.dirname(environ['SCRIPT_FILENAME'])
sys.path.insert(0, scriptsdir)
import kojihub
def get_memory_usage():
pagesize = resource.getpagesize()
statm = [pagesize * int(y) // 1024
@ -736,7 +729,6 @@ def server_setup(environ):
'Hub option DisableGSSAPIProxyDNFallback is deprecated and '
'will be removed in 1.29')
setup_logging2(opts)
load_scripts(environ)
koji.util.setup_rlimits(opts)
plugins = load_plugins(opts)
registry = get_registry(opts, plugins)

View file

@ -4,14 +4,11 @@
import random
import sys
import koji
from koji.context import context
from koji.plugin import export
# XXX - have to import kojihub for make_task
sys.path.insert(0, '/usr/share/koji-hub/')
import kojihub # noqa: E402
import kojihub
__all__ = ('runroot',)

View file

@ -1,10 +1,7 @@
import sys
import koji
from koji.context import context
from koji.plugin import export
sys.path.insert(0, '/usr/share/koji-hub/')
import kojihub # noqa: E402
import kojihub
__all__ = ('saveFailedTree',)

View file

@ -1,15 +1,13 @@
# Copyright © 2019 Red Hat, Inc.
#
# SPDX-License-Identifier: GPL-2.0-or-later
import sys
import koji
from koji.db import QueryProcessor, nextval
from koji.context import context
from koji.plugin import callback, export
import koji.policy
sys.path.insert(0, "/usr/share/koji-hub/")
from kojihub import ( # noqa: E402
from kojihub import (
_create_build_target,
_create_tag,
_delete_build_target,

View file

@ -3,7 +3,9 @@ import unittest
import mock
import koji
import koji.db
import kojihub
import kojihub.kojihub
IP = kojihub.InsertProcessor
QP = kojihub.QueryProcessor
@ -11,19 +13,18 @@ QP = kojihub.QueryProcessor
class TestAddArchiveType(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.session.assertPerm = mock.MagicMock()
self.exports = kojihub.RootExports()
self.channel_name = 'test-channel'
self.description = 'test-description'
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.insert_execute = mock.MagicMock()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.get_archive_type = mock.patch('kojihub.get_archive_type').start()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.get_archive_type = mock.patch('kojihub.kojihub.get_archive_type').start()
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.query_execute = mock.MagicMock()
@ -63,7 +64,7 @@ class TestAddArchiveType(unittest.TestCase):
self.query_execute.side_effect = [[]]
self.verify_name_internal.return_value = None
self.get_archive_type.return_value = None
kojihub.add_archive_type('jar', 'Jar package', 'jar', 'zip')
kojihub.add_archive_type('jar', 'Jar package', 'jar', compression_type='zip')
self.assertEqual(len(self.inserts), 1)
insert = self.inserts[0]

View file

@ -10,12 +10,12 @@ IP = kojihub.InsertProcessor
class TestAddBType(unittest.TestCase):
@mock.patch('kojihub.verify_name_internal')
@mock.patch('kojihub.list_btypes')
@mock.patch('kojihub.InsertProcessor')
@mock.patch('kojihub.kojihub.verify_name_internal')
@mock.patch('kojihub.kojihub.list_btypes')
@mock.patch('kojihub.kojihub.InsertProcessor')
def test_add_btype(self, InsertProcessor, list_btypes, verify_name_internal):
# Not sure why mock can't patch kojihub.context, so we do this
session = kojihub.context.session = mock.MagicMock()
session = kojihub.kojihub.context.session = mock.MagicMock()
mocks = [InsertProcessor, list_btypes, session]
# It seems MagicMock will not automatically handle attributes that
# start with "assert"

View file

@ -13,18 +13,18 @@ class TestAddChannel(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.session.assertPerm = mock.MagicMock()
self.exports = kojihub.RootExports()
self.channel_name = 'test-channel'
self.description = 'test-description'
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.insert_execute = mock.MagicMock()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.get_channel = mock.patch('kojihub.get_channel').start()
self.nextval = mock.patch('kojihub.nextval').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.get_channel = mock.patch('kojihub.kojihub.get_channel').start()
self.nextval = mock.patch('kojihub.kojihub.nextval').start()
def tearDown(self):
mock.patch.stopall()

View file

@ -9,9 +9,9 @@ class TestAddExternalRepoToTag(unittest.TestCase):
def setUp(self):
self.tag_name = 'test-tag'
self.get_tag = mock.patch('kojihub.get_tag').start()
self.get_external_repo = mock.patch('kojihub.get_external_repo').start()
self.get_tag_external_repos = mock.patch('kojihub.get_tag_external_repos').start()
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
self.get_external_repo = mock.patch('kojihub.kojihub.get_external_repo').start()
self.get_tag_external_repos = mock.patch('kojihub.kojihub.get_tag_external_repos').start()
self.parse_arches = mock.patch('koji.parse_arches').start()
self.tag_info = {'id': 1, 'name': self.tag_name}
self.external_repo_info = {'id': 123, 'name': 'test-repo'}

View file

@ -15,11 +15,11 @@ class FakeException(Exception):
class TestAddExternalRPM(unittest.TestCase):
def setUp(self):
self.get_rpm = mock.patch('kojihub.get_rpm').start()
self.get_external_repo_id = mock.patch('kojihub.get_external_repo_id').start()
self.nextval = mock.patch('kojihub.nextval').start()
self.Savepoint = mock.patch('kojihub.Savepoint').start()
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.get_rpm = mock.patch('kojihub.kojihub.get_rpm').start()
self.get_external_repo_id = mock.patch('kojihub.kojihub.get_external_repo_id').start()
self.nextval = mock.patch('kojihub.kojihub.nextval').start()
self.Savepoint = mock.patch('kojihub.kojihub.Savepoint').start()
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.insert_execute = mock.MagicMock()

View file

@ -10,7 +10,7 @@ class TestAddGroupMember(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.get_user = mock.patch('kojihub.get_user').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
def test_non_exist_user(self):
data = [{'id': 3,

View file

@ -32,16 +32,16 @@ class TestAddHost(unittest.TestCase):
return query
def setUp(self):
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context_db = mock.patch('koji.db.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
@ -49,11 +49,11 @@ class TestAddHost(unittest.TestCase):
self.context.session.assertPerm = mock.MagicMock()
self.context.opts = {'HostPrincipalFormat': '-%s-'}
self.exports = kojihub.RootExports()
self.verify_host_name = mock.patch('kojihub.verify_host_name').start()
self.verify_name_user = mock.patch('kojihub.verify_name_user').start()
self.get_host = mock.patch('kojihub.get_host').start()
self.nextval = mock.patch('kojihub.nextval').start()
self.get_user = mock.patch('kojihub.get_user').start()
self.verify_host_name = mock.patch('kojihub.kojihub.verify_host_name').start()
self.verify_name_user = mock.patch('kojihub.kojihub.verify_name_user').start()
self.get_host = mock.patch('kojihub.kojihub.get_host').start()
self.nextval = mock.patch('kojihub.kojihub.nextval').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.query_singleValue = mock.MagicMock()
def tearDown(self):
@ -80,7 +80,7 @@ class TestAddHost(unittest.TestCase):
self.assertEqual(r, 12)
self.context.session.assertPerm.assert_called_once_with('host')
kojihub.get_host.assert_called_once_with('hostname')
self.get_host.assert_called_once_with('hostname')
self.context.session.createUser.assert_called_once_with(
'hostname', usertype=koji.USERTYPES['HOST'], krb_principal='-hostname-')
self.nextval.assert_called_once_with('host_id_seq')
@ -191,7 +191,7 @@ class TestAddHost(unittest.TestCase):
self.exports.addHost('hostname', ['i386', 'x86_64'], krb_principal=krb_principal)
self.context.session.assertPerm.assert_called_once_with('host')
kojihub.get_host.assert_called_once_with('hostname')
self.get_host.assert_called_once_with('hostname')
self.context.session.createUser.assert_not_called()
self.verify_host_name.assert_called_once_with('hostname')
self.nextval.assert_not_called()

View file

@ -16,10 +16,10 @@ class TestAddHostToChannel(unittest.TestCase):
return insert
def setUp(self):
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context_db = mock.patch('koji.db.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
@ -29,11 +29,11 @@ class TestAddHostToChannel(unittest.TestCase):
self.context_db.session.user_id = 23
self.context.opts = {'HostPrincipalFormat': '-%s-'}
self.exports = kojihub.RootExports()
self.get_channel = mock.patch('kojihub.get_channel').start()
self.list_channels = mock.patch('kojihub.list_channels').start()
self.get_channel_id = mock.patch('kojihub.get_channel_id').start()
self.get_host = mock.patch('kojihub.get_host').start()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.get_channel = mock.patch('kojihub.kojihub.get_channel').start()
self.list_channels = mock.patch('kojihub.kojihub.list_channels').start()
self.get_channel_id = mock.patch('kojihub.kojihub.get_channel_id').start()
self.get_host = mock.patch('kojihub.kojihub.get_host').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.cname = 'channel_name'
self.name = 'hostname'
self.host_info = {'id': 123, 'name': self.name}

View file

@ -24,14 +24,14 @@ class TestAddRPMSig(unittest.TestCase):
return query
def setUp(self):
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.query_execute = mock.MagicMock()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertLogin = mock.MagicMock()
@ -44,11 +44,11 @@ class TestAddRPMSig(unittest.TestCase):
mock.patch.stopall()
@mock.patch('koji.plugin.run_callbacks')
@mock.patch('kojihub.get_rpm')
@mock.patch('kojihub.get_build')
@mock.patch('kojihub.kojihub.get_rpm')
@mock.patch('kojihub.kojihub.get_build')
@mock.patch('os.path.isdir')
@mock.patch('koji.ensuredir')
@mock.patch('kojihub.open')
@mock.patch('kojihub.kojihub.open')
def test_add_rpm_sig_header_signed(
self,
open,

View file

@ -8,9 +8,9 @@ import copy
class TestAddUserKrbPrincipal(unittest.TestCase):
def setUp(self):
self.get_user = mock.patch('kojihub.get_user').start()
self.verify_name_user = mock.patch('kojihub.verify_name_user').start()
self.get_user_by_krb_principal = mock.patch('kojihub.get_user_by_krb_principal').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.verify_name_user = mock.patch('kojihub.kojihub.verify_name_user').start()
self.get_user_by_krb_principal = mock.patch('kojihub.kojihub.get_user_by_krb_principal').start()
self.username = 'testuser'
self.krbprincipal = '%s@TEST.COM' % self.username
self.userinfo = {'id': 1, 'name': self.username}

View file

@ -9,8 +9,8 @@ import kojihub
class TestAddVolume(unittest.TestCase):
def setUp(self):
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.context').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertPerm = mock.MagicMock()

View file

@ -1,7 +1,7 @@
import copy
import unittest
import kojihub
from kojihub.kojihub import _applyQueryOpts
class TestApplyQueryOpts(unittest.TestCase):
@ -15,7 +15,7 @@ class TestApplyQueryOpts(unittest.TestCase):
def test_basic(self):
opts = None
expected = copy.copy(self.original)
actual = kojihub._applyQueryOpts(self.original, opts)
actual = _applyQueryOpts(self.original, opts)
self.assertEqual(expected, actual)
def test_order_by_foo(self):
@ -25,7 +25,7 @@ class TestApplyQueryOpts(unittest.TestCase):
{'foo': 1, 'bar': 1},
{'foo': 2, 'bar': -1},
]
actual = kojihub._applyQueryOpts(self.original, opts)
actual = _applyQueryOpts(self.original, opts)
self.assertEqual(expected, actual)
def test_order_by_bar(self):
@ -35,7 +35,7 @@ class TestApplyQueryOpts(unittest.TestCase):
{'foo': 0, 'bar': 0},
{'foo': 1, 'bar': 1},
]
actual = kojihub._applyQueryOpts(self.original, opts)
actual = _applyQueryOpts(self.original, opts)
self.assertEqual(expected, actual)
def test_order_in_reverse(self):
@ -45,7 +45,7 @@ class TestApplyQueryOpts(unittest.TestCase):
{'foo': 1, 'bar': 1},
{'foo': 0, 'bar': 0},
]
actual = kojihub._applyQueryOpts(self.original, opts)
actual = _applyQueryOpts(self.original, opts)
self.assertEqual(expected, actual)
def test_offset(self):
@ -54,7 +54,7 @@ class TestApplyQueryOpts(unittest.TestCase):
{'foo': 2, 'bar': -1},
{'foo': 0, 'bar': 0},
]
actual = kojihub._applyQueryOpts(self.original, opts)
actual = _applyQueryOpts(self.original, opts)
self.assertEqual(expected, actual)
def test_limit(self):
@ -63,7 +63,7 @@ class TestApplyQueryOpts(unittest.TestCase):
{'foo': 1, 'bar': 1},
{'foo': 2, 'bar': -1},
]
actual = kojihub._applyQueryOpts(self.original, opts)
actual = _applyQueryOpts(self.original, opts)
self.assertEqual(expected, actual)
def test_limit_and_offset(self):
@ -71,16 +71,16 @@ class TestApplyQueryOpts(unittest.TestCase):
expected = [
{'foo': 2, 'bar': -1},
]
actual = kojihub._applyQueryOpts(self.original, opts)
actual = _applyQueryOpts(self.original, opts)
self.assertEqual(expected, actual)
def test_count_only(self):
opts = {'countOnly': True}
expected = 3
actual = kojihub._applyQueryOpts(self.original, opts)
actual = _applyQueryOpts(self.original, opts)
self.assertEqual(expected, actual)
opts = {'countOnly': True, 'offset': 2}
expected = 1
actual = kojihub._applyQueryOpts(self.original, opts)
actual = _applyQueryOpts(self.original, opts)
self.assertEqual(expected, actual)

View file

@ -7,12 +7,12 @@ import mock
class TestBuild(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.exports = kojihub.RootExports()
self.context.session.assertLogin = mock.MagicMock()
self.context.session.hasPerm = mock.MagicMock()
self.get_channel = mock.patch('kojihub.get_channel').start()
self.make_task = mock.patch('kojihub.make_task').start()
self.get_channel = mock.patch('kojihub.kojihub.get_channel').start()
self.make_task = mock.patch('kojihub.kojihub.make_task').start()
self.src = 'test-src'
self.target = 'test-target'

View file

@ -7,11 +7,11 @@ import mock
class TestBuildImage(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.exports = kojihub.RootExports()
self.context.session.assertPerm = mock.MagicMock()
self.context.session.hasPerm = mock.MagicMock()
self.make_task = mock.patch('kojihub.make_task').start()
self.make_task = mock.patch('kojihub.kojihub.make_task').start()
self.mock_parse_arches = mock.patch('koji.parse_arches').start()
self.name = 'image-name'
self.version = 'test-version'

View file

@ -7,7 +7,7 @@ import mock
class TestBuildImageIndirection(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.exports = kojihub.RootExports()
self.context.session.assertPerm = mock.MagicMock()
self.context.session.hasPerm = mock.MagicMock()

View file

@ -7,7 +7,7 @@ import mock
class TestBuildImageOz(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.exports = kojihub.RootExports()
self.context.session.assertPerm = mock.MagicMock()
self.context.session.hasPerm = mock.MagicMock()

View file

@ -19,14 +19,14 @@ class TestCGImporter(unittest.TestCase):
os.mkdir(self.TMP_PATH)
self.path_work = mock.patch('koji.pathinfo.work').start()
self.context_db = mock.patch('koji.db.context').start()
self.context = mock.patch('kojihub.context').start()
self.get_build = mock.patch('kojihub.get_build').start()
self.get_user = mock.patch('kojihub.get_user').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.userinfo = {'id': 123}
self.rmtree = mock.patch('koji.util.rmtree').start()
self.lexists = mock.patch('os.path.lexists').start()
self.path_build = mock.patch('koji.pathinfo.build').start()
self.new_build = mock.patch('kojihub.new_build').start()
self.new_build = mock.patch('kojihub.kojihub.new_build').start()
def tearDown(self):
if os.path.exists(self.TMP_PATH):
@ -166,7 +166,7 @@ class TestCGImporter(unittest.TestCase):
x.get_metadata('default.json', 'cg_importer_json')
x.import_metadata()
@mock.patch("kojihub.CG_Importer.get_metadata")
@mock.patch("kojihub.kojihub.CG_Importer.get_metadata")
def test_do_import_no_such_metadata(self, get_metadata):
x = kojihub.CG_Importer()
metadata = {'metadata_version': 99,
@ -213,8 +213,8 @@ class TestMatchKojiFile(unittest.TestCase):
'nvr': self.build1['nvr'],
'filename': self.archive1['filename'],
}
self.get_archive = mock.patch('kojihub.get_archive').start()
self.get_build = mock.patch('kojihub.get_build').start()
self.get_archive = mock.patch('kojihub.kojihub.get_archive').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
def tearDown(self):
mock.patch.stopall()
@ -264,9 +264,9 @@ class TestCGReservation(unittest.TestCase):
return update
def setUp(self):
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.inserts = []
self.updates = []
@ -275,13 +275,14 @@ class TestCGReservation(unittest.TestCase):
self.context_db.session.user_id = 123456
self.mock_cursor = mock.MagicMock()
self.context_db.cnx.cursor.return_value = self.mock_cursor
self.get_build = mock.patch('kojihub.get_build').start()
self.get_user = mock.patch('kojihub.get_user').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.userinfo = {'id': 123456, 'name': 'username'}
self.new_build = mock.patch('kojihub.new_build').start()
self.lookup_name = mock.patch('kojihub.lookup_name').start()
self.assert_cg = mock.patch('kojihub.assert_cg').start()
self.get_reservation_token = mock.patch('kojihub.get_reservation_token').start()
self.new_build = mock.patch('kojihub.kojihub.new_build').start()
self.lookup_name = mock.patch('kojihub.kojihub.lookup_name').start()
self.assert_cg = mock.patch('kojihub.kojihub.assert_cg').start()
self.get_reservation_token = mock.patch('kojihub.kojihub.get_reservation_token').start()
self.run_callbacks = mock.patch('koji.plugin.run_callbacks').start()
def tearDown(self):

View file

@ -7,12 +7,12 @@ import mock
class TestChainBuild(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.exports = kojihub.RootExports()
self.context.session.assertLogin = mock.MagicMock()
self.context.session.hasPerm = mock.MagicMock()
self.get_channel = mock.patch('kojihub.get_channel').start()
self.make_task = mock.patch('kojihub.make_task').start()
self.get_channel = mock.patch('kojihub.kojihub.get_channel').start()
self.make_task = mock.patch('kojihub.kojihub.make_task').start()
self.srcs = ['pkg1']
self.target = 'test-target'

View file

@ -7,12 +7,12 @@ import mock
class TestChainMaven(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.exports = kojihub.RootExports()
self.context.session.assertLogin = mock.MagicMock()
self.context.session.hasPerm = mock.MagicMock()
self.get_channel = mock.patch('kojihub.get_channel').start()
self.make_task = mock.patch('kojihub.make_task').start()
self.get_channel = mock.patch('kojihub.kojihub.get_channel').start()
self.make_task = mock.patch('kojihub.kojihub.make_task').start()
self.builds = {'build1': {}, 'build2': {}, 'build3': {}}
self.target = 'test-target'

View file

@ -3,7 +3,7 @@ import unittest
import koji
import koji.policy
import kojihub
import kojixmlrpc
from kojihub import kojixmlrpc
class OurException(Exception):
@ -23,8 +23,8 @@ class FakePlugin(object):
class TestCheckVolumePolicy(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.lookup_name = mock.patch('kojihub.lookup_name').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.lookup_name = mock.patch('kojihub.kojihub.lookup_name').start()
def tearDown(self):
mock.patch.stopall()

View file

@ -53,21 +53,21 @@ class TestCompleteImageBuild(unittest.TestCase):
mock.patch('koji.pathinfo', new=self.pathinfo).start()
self.hostcalls = kojihub.HostExports()
self.context_db = mock.patch('koji.db.context').start()
mock.patch('kojihub.Host').start()
self.Task = mock.patch('kojihub.Task').start()
mock.patch('kojihub.kojihub.Host').start()
self.Task = mock.patch('kojihub.kojihub.Task').start()
self.Task.return_value.assertHost = mock.MagicMock()
self.get_build = mock.patch('kojihub.get_build').start()
mock.patch('kojihub.get_rpm', new=self.my_get_rpm).start()
self.get_image_build = mock.patch('kojihub.get_image_build').start()
mock.patch('kojihub.get_archive_type', new=self.my_get_archive_type).start()
mock.patch('kojihub.lookup_name', new=self.my_lookup_name).start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
mock.patch('kojihub.kojihub.get_rpm', new=self.my_get_rpm).start()
self.get_image_build = mock.patch('kojihub.kojihub.get_image_build').start()
mock.patch('kojihub.kojihub.get_archive_type', new=self.my_get_archive_type).start()
mock.patch('kojihub.kojihub.lookup_name', new=self.my_lookup_name).start()
mock.patch.object(kojihub.BuildRoot, 'load', new=self.my_buildroot_load).start()
mock.patch('kojihub.import_archive_internal',
mock.patch('kojihub.kojihub.import_archive_internal',
new=self.my_import_archive_internal).start()
self._dml = mock.patch('kojihub._dml').start()
mock.patch('kojihub.build_notification').start()
mock.patch('kojihub.assert_policy').start()
mock.patch('kojihub.check_volume_policy',
self._dml = mock.patch('kojihub.kojihub._dml').start()
mock.patch('kojihub.kojihub.build_notification').start()
mock.patch('kojihub.kojihub.assert_policy').start()
mock.patch('kojihub.kojihub.check_volume_policy',
return_value={'id': 0, 'name': 'DEFAULT'}).start()
self.set_up_callbacks()
self.rpms = {}
@ -79,7 +79,7 @@ class TestCompleteImageBuild(unittest.TestCase):
new=make_bulk_insert_grabber(self)).start()
mock.patch.object(kojihub.UpdateProcessor, 'execute',
new=make_update_grabber(self)).start()
mock.patch('kojihub.nextval', new=self.my_nextval).start()
mock.patch('kojihub.kojihub.nextval', new=self.my_nextval).start()
self.sequences = {}
def tearDown(self):
@ -173,8 +173,8 @@ class TestCompleteImageBuild(unittest.TestCase):
def my_ga(archive_id, **kw):
return share['archiveinfo']
with mock.patch('kojihub.InsertProcessor', new=my_ip):
with mock.patch('kojihub.get_archive', new=my_ga):
with mock.patch('kojihub.kojihub.InsertProcessor', new=my_ip):
with mock.patch('kojihub.kojihub.get_archive', new=my_ga):
return orig_import_archive_internal(*a, **kw)
def set_up_callbacks(self):

View file

@ -21,24 +21,24 @@ class TestCompleteMavenBuild(unittest.TestCase):
self.pathinfo = koji.PathInfo(self.tempdir)
mock.patch('koji.pathinfo', new=self.pathinfo).start()
self.hostcalls = kojihub.HostExports()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context_db = mock.patch('koji.db.context').start()
self.context.opts = {'EnableMaven': True}
mock.patch('kojihub.Host').start()
self.Task = mock.patch('kojihub.Task').start()
mock.patch('kojihub.kojihub.Host').start()
self.Task = mock.patch('kojihub.kojihub.Task').start()
self.Task.return_value.assertHost = mock.MagicMock()
self.get_build = mock.patch('kojihub.get_build').start()
self.get_maven_build = mock.patch('kojihub.get_maven_build').start()
self.get_archive_type = mock.patch('kojihub.get_archive_type').start()
mock.patch('kojihub.lookup_name', new=self.my_lookup_name).start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.get_maven_build = mock.patch('kojihub.kojihub.get_maven_build').start()
self.get_archive_type = mock.patch('kojihub.kojihub.get_archive_type').start()
mock.patch('kojihub.kojihub.lookup_name', new=self.my_lookup_name).start()
mock.patch.object(kojihub.BuildRoot, 'load', new=self.my_buildroot_load).start()
mock.patch('kojihub.import_archive_internal',
mock.patch('kojihub.kojihub.import_archive_internal',
new=self.my_import_archive_internal).start()
mock.patch('koji.db._dml').start()
mock.patch('koji.db._fetchSingle').start()
mock.patch('kojihub.build_notification').start()
mock.patch('kojihub.assert_policy').start()
mock.patch('kojihub.check_volume_policy',
mock.patch('kojihub.kojihub.build_notification').start()
mock.patch('kojihub.kojihub.assert_policy').start()
mock.patch('kojihub.kojihub.check_volume_policy',
return_value={'id': 0, 'name': 'DEFAULT'}).start()
self.set_up_callbacks()
@ -96,8 +96,8 @@ class TestCompleteMavenBuild(unittest.TestCase):
def my_ga(archive_id, **kw):
return share['archiveinfo']
with mock.patch('kojihub.InsertProcessor', new=my_ip):
with mock.patch('kojihub.get_archive', new=my_ga):
with mock.patch('kojihub.kojihub.InsertProcessor', new=my_ip):
with mock.patch('kojihub.kojihub.get_archive', new=my_ga):
orig_import_archive_internal(*a, **kw)
def set_up_callbacks(self):

View file

@ -10,10 +10,10 @@ import kojihub
class TestCreateBuildTarget(unittest.TestCase):
def setUp(self):
self.get_build_targets = mock.patch('kojihub.get_build_targets').start()
self.get_tag = mock.patch('kojihub.get_tag').start()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.context').start()
self.get_build_targets = mock.patch('kojihub.kojihub.get_build_targets').start()
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertPerm = mock.MagicMock()

View file

@ -10,9 +10,9 @@ import kojihub
class TestCreateExternalRepo(unittest.TestCase):
def setUp(self):
self.get_external_repos = mock.patch('kojihub.get_external_repos').start()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.context').start()
self.get_external_repos = mock.patch('kojihub.kojihub.get_external_repos').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertPerm = mock.MagicMock()

View file

@ -11,9 +11,9 @@ IP = kojihub.InsertProcessor
class TestCreateImageBuild(unittest.TestCase):
def setUp(self):
self.get_build = mock.patch('kojihub.get_build').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.exports = kojihub.RootExports()
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.insert_execute = mock.MagicMock()

View file

@ -11,13 +11,13 @@ IP = kojihub.InsertProcessor
class TestCreateMavenBuild(unittest.TestCase):
def setUp(self):
self.get_build = mock.patch('kojihub.get_build').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.exports = kojihub.RootExports()
self.session = mock.MagicMock()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context_db = mock.patch('koji.db.context').start()
self.context.session.assertPerm = mock.MagicMock()
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.insert_execute = mock.MagicMock()

View file

@ -29,23 +29,23 @@ class TestCreateNotification(unittest.TestCase):
return update
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.opts = {
'EmailDomain': 'test.domain.com',
'NotifyOnSuccess': True,
}
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.get_build_notifications = mock.patch('kojihub.get_build_notifications').start()
self.get_tag_id = mock.patch('kojihub.get_tag_id').start()
self.get_package_id = mock.patch('kojihub.get_package_id').start()
self.get_build_notifications = mock.patch('kojihub.kojihub.get_build_notifications').start()
self.get_tag_id = mock.patch('kojihub.kojihub.get_tag_id').start()
self.get_package_id = mock.patch('kojihub.kojihub.get_package_id').start()
self.exports = kojihub.RootExports()
self.exports.getLoggedInUser = mock.MagicMock()

View file

@ -29,25 +29,25 @@ class TestCreateNotificationBlock(unittest.TestCase):
return update
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.opts = {
'EmailDomain': 'test.domain.com',
'NotifyOnSuccess': True,
}
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.get_tag_id = mock.patch('kojihub.get_tag_id').start()
self.get_package_id = mock.patch('kojihub.get_package_id').start()
self.get_tag_id = mock.patch('kojihub.kojihub.get_tag_id').start()
self.get_package_id = mock.patch('kojihub.kojihub.get_package_id').start()
self.get_build_notification_blocks = mock.patch(
'kojihub.get_build_notification_blocks').start()
'kojihub.kojihub.get_build_notification_blocks').start()
self.exports = kojihub.RootExports()
self.exports.getLoggedInUser = mock.MagicMock()

View file

@ -18,16 +18,16 @@ class TestCreateTag(unittest.TestCase):
return insert
def setUp(self):
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self._dml = mock.patch('kojihub._dml').start()
self.get_tag = mock.patch('kojihub.get_tag').start()
self.get_tag_id = mock.patch('kojihub.get_tag_id').start()
self.get_perm_id = mock.patch('kojihub.get_perm_id').start()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.writeInheritanceData = mock.patch('kojihub._writeInheritanceData').start()
self.context = mock.patch('kojihub.context').start()
self._dml = mock.patch('kojihub.kojihub._dml').start()
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
self.get_tag_id = mock.patch('kojihub.kojihub.get_tag_id').start()
self.get_perm_id = mock.patch('kojihub.kojihub.get_perm_id').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.writeInheritanceData = mock.patch('kojihub.kojihub._writeInheritanceData').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context_db = mock.patch('koji.db.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"

View file

@ -9,11 +9,11 @@ import kojihub
class TestCreateUser(unittest.TestCase):
def setUp(self):
self.verify_name_user = mock.patch('kojihub.verify_name_user').start()
self.get_user = mock.patch('kojihub.get_user').start()
self.get_user_by_krb_principal = mock.patch('kojihub.get_user_by_krb_principal').start()
self.verify_name_user = mock.patch('kojihub.kojihub.verify_name_user').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.get_user_by_krb_principal = mock.patch('kojihub.kojihub.get_user_by_krb_principal').start()
self.exports = kojihub.RootExports()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertPerm = mock.MagicMock()

View file

@ -11,12 +11,12 @@ IP = kojihub.InsertProcessor
class TestCreateWinBuild(unittest.TestCase):
def setUp(self):
self.get_build = mock.patch('kojihub.get_build').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.exports = kojihub.RootExports()
self.session = mock.MagicMock()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.session.assertPerm = mock.MagicMock()
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.insert_execute = mock.MagicMock()

View file

@ -9,8 +9,8 @@ import kojihub
class TestDeleteBuild(unittest.TestCase):
@mock.patch('kojihub.context')
@mock.patch('kojihub.get_build')
@mock.patch('kojihub.kojihub.context')
@mock.patch('kojihub.kojihub.get_build')
def test_delete_build_raise_error(self, build, context):
context.session.assertPerm = mock.MagicMock()
references = ['tags', 'rpms', 'archives', 'component_of']
@ -18,15 +18,15 @@ class TestDeleteBuild(unittest.TestCase):
context = mock.MagicMock()
context.session.return_value = context
with mock.patch('kojihub.build_references') as refs:
with mock.patch('kojihub.kojihub.build_references') as refs:
retval = defaultdict(dict)
retval[ref] = True
refs.return_value = retval
with self.assertRaises(koji.GenericError):
kojihub.delete_build(build='', strict=True)
@mock.patch('kojihub.context')
@mock.patch('kojihub.get_build')
@mock.patch('kojihub.kojihub.context')
@mock.patch('kojihub.kojihub.get_build')
def test_delete_build_return_false(self, build, context):
context.session.assertPerm = mock.MagicMock()
references = ['tags', 'rpms', 'archives', 'component_of']
@ -34,14 +34,14 @@ class TestDeleteBuild(unittest.TestCase):
context = mock.MagicMock()
context.session.return_value = context
with mock.patch('kojihub.build_references') as refs:
with mock.patch('kojihub.kojihub.build_references') as refs:
retval = defaultdict(dict)
retval[ref] = True
refs.return_value = retval
assert kojihub.delete_build(build='', strict=False) is False
@mock.patch('kojihub.context')
@mock.patch('kojihub.get_build')
@mock.patch('kojihub.kojihub.context')
@mock.patch('kojihub.kojihub.get_build')
def test_delete_build_check_last_used_raise_error(self, build, context):
context.session.assertPerm = mock.MagicMock()
references = ['tags', 'rpms', 'archives', 'component_of', 'last_used']
@ -49,18 +49,18 @@ class TestDeleteBuild(unittest.TestCase):
context = mock.MagicMock()
context.session.return_value = context
with mock.patch('kojihub.build_references') as refs:
with mock.patch('kojihub.kojihub.build_references') as refs:
retval = defaultdict(dict)
if ref == 'last_used':
retval[ref] = time.time() + 100
refs.return_value = retval
self.assertFalse(kojihub.delete_build(build='', strict=False))
@mock.patch('kojihub.get_user')
@mock.patch('kojihub._delete_build')
@mock.patch('kojihub.build_references')
@mock.patch('kojihub.context')
@mock.patch('kojihub.get_build')
@mock.patch('kojihub.kojihub.get_user')
@mock.patch('kojihub.kojihub._delete_build')
@mock.patch('kojihub.kojihub.build_references')
@mock.patch('kojihub.kojihub.context')
@mock.patch('kojihub.kojihub.get_build')
def test_delete_build_lazy_refs(self, build, context, buildrefs, _delete, get_user):
'''Test that we can handle lazy return from build_references'''
get_user.return_value = {'authtype': 2, 'id': 1, 'krb_principal': None,

View file

@ -9,7 +9,7 @@ import kojihub
class TestDeleteBuildTarget(unittest.TestCase):
def setUp(self):
self.lookup_name = mock.patch('kojihub.lookup_name').start()
self.lookup_name = mock.patch('kojihub.kojihub.lookup_name').start()
self.exports = kojihub.RootExports()
def test_non_exist_target(self):

View file

@ -15,12 +15,12 @@ class TestDeleteNotifications(unittest.TestCase):
return delete
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.opts = {
'EmailDomain': 'test.domain.com',
'NotifyOnSuccess': True,
}
self.DeleteProcessor = mock.patch('kojihub.DeleteProcessor',
self.DeleteProcessor = mock.patch('kojihub.kojihub.DeleteProcessor',
side_effect=self.getDelete).start()
self.deletes = []

View file

@ -15,16 +15,16 @@ class TestDeleteNotificationsBlocks(unittest.TestCase):
return delete
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.opts = {
'EmailDomain': 'test.domain.com',
'NotifyOnSuccess': True,
}
self.DeleteProcessor = mock.patch('kojihub.DeleteProcessor',
self.DeleteProcessor = mock.patch('kojihub.kojihub.DeleteProcessor',
side_effect=self.getDelete).start()
self.deletes = []
self.get_user = mock.patch('kojihub.get_user').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.exports = kojihub.RootExports()
self.exports.getLoggedInUser = mock.MagicMock()

View file

@ -17,13 +17,13 @@ class TestDeleteRPMSig(unittest.TestCase):
return delete
def setUp(self):
self.DeleteProcessor = mock.patch('kojihub.DeleteProcessor',
self.DeleteProcessor = mock.patch('kojihub.kojihub.DeleteProcessor',
side_effect=self.getDelete).start()
self.deletes = []
self.get_rpm = mock.patch('kojihub.get_rpm').start()
self.query_rpm_sigs = mock.patch('kojihub.query_rpm_sigs').start()
self.get_build = mock.patch('kojihub.get_build').start()
self.get_user = mock.patch('kojihub.get_user').start()
self.get_rpm = mock.patch('kojihub.kojihub.get_rpm').start()
self.query_rpm_sigs = mock.patch('kojihub.kojihub.query_rpm_sigs').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.buildinfo = {'build_id': 1,
'epoch': None,
'extra': None,

View file

@ -15,11 +15,11 @@ class TestDeleteTag(unittest.TestCase):
return update
def setUp(self):
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.get_tag = mock.patch('kojihub.get_tag').start()
self.context = mock.patch('kojihub.context').start()
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context_db = mock.patch('koji.db.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"

View file

@ -18,8 +18,8 @@ class TestDisableChannel(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.get_channel = mock.patch('kojihub.get_channel').start()
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.get_channel = mock.patch('kojihub.kojihub.get_channel').start()
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.channelname = 'test-channel'

View file

@ -10,7 +10,7 @@ class TestDisableUser(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.get_user = mock.patch('kojihub.get_user').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
def test_non_exist_user(self):
username = 'test-user'

View file

@ -23,15 +23,15 @@ class TestDistRepoInit(unittest.TestCase):
self.pathinfo = koji.PathInfo(self.tempdir)
mock.patch('koji.pathinfo', new=self.pathinfo).start()
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.get_tag = mock.patch('kojihub.get_tag').start()
self.get_event = mock.patch('kojihub.get_event').start()
self.nextval = mock.patch('kojihub.nextval').start()
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
self.get_event = mock.patch('kojihub.kojihub.get_event').start()
self.nextval = mock.patch('kojihub.kojihub.nextval').start()
self.copyfile = mock.patch('shutil.copyfile').start()
self.lookup_name = mock.patch('kojihub.lookup_name').start()
self.lookup_name = mock.patch('kojihub.kojihub.lookup_name').start()
self.get_tag.return_value = {'id': 42, 'name': 'tag'}
self.get_event.return_value = 12345
@ -105,9 +105,9 @@ class TestDistRepoInit(unittest.TestCase):
class TestDistRepo(unittest.TestCase):
@mock.patch('kojihub.assert_policy')
@mock.patch('kojihub.dist_repo_init')
@mock.patch('kojihub.make_task')
@mock.patch('kojihub.kojihub.assert_policy')
@mock.patch('kojihub.kojihub.dist_repo_init')
@mock.patch('kojihub.kojihub.make_task')
def test_DistRepo(self, make_task, dist_repo_init, assert_policy):
session = kojihub.context.session = mock.MagicMock()
session.user_id = 123
@ -210,10 +210,10 @@ class TestDistRepoMove(unittest.TestCase):
koji.dump_json("%s/repo_manifest" % uploaddir, self.files)
# mocks
self.repo_info = mock.patch('kojihub.repo_info').start()
self.repo_info = mock.patch('kojihub.kojihub.repo_info').start()
self.repo_info.return_value = self.rinfo.copy()
self.get_rpm = mock.patch('kojihub.get_rpm').start()
self.get_build = mock.patch('kojihub.get_build').start()
self.get_rpm = mock.patch('kojihub.kojihub.get_rpm').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.get_rpm.side_effect = self.our_get_rpm
self.get_build.side_effect = self.our_get_build

View file

@ -19,9 +19,9 @@ class TestEditBuildTarget(unittest.TestCase):
return query
def setUp(self):
self.lookup_build_target = mock.patch('kojihub.lookup_build_target').start()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.get_tag = mock.patch('kojihub.get_tag').start()
self.lookup_build_target = mock.patch('kojihub.kojihub.lookup_build_target').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
self.exports = kojihub.RootExports()
self.target_name = 'build-target'
self.name = 'build-target-rename'
@ -32,7 +32,7 @@ class TestEditBuildTarget(unittest.TestCase):
self.dest_tag_info = {'id': 112, 'name': self.dest_tag}
self.session = kojihub.context.session = mock.MagicMock()
self.session.assertPerm = mock.MagicMock()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.query_singleValue = mock.MagicMock()

View file

@ -23,21 +23,21 @@ class TestEditChannel(unittest.TestCase):
return update
def setUp(self):
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.session.assertPerm = mock.MagicMock()
self.exports = kojihub.RootExports()
self.channel_name = 'test-channel'
self.channel_name_new = 'test-channel-2'
self.channel_info = {'id': 123, 'name': self.channel_name, 'description': 'description',
'comment': 'comment'}
self.get_channel = mock.patch('kojihub.get_channel').start()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.get_channel = mock.patch('kojihub.kojihub.get_channel').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
def tearDown(self):
mock.patch.stopall()
@ -74,7 +74,7 @@ class TestEditChannel(unittest.TestCase):
def test_edit_channel_valid(self):
self.verify_name_internal.return_value = None
kojihub.get_channel.side_effect = [self.channel_info, {}]
self.get_channel.side_effect = [self.channel_info, {}]
r = self.exports.editChannel(self.channel_name, name=self.channel_name_new,
description='description_new')
@ -108,7 +108,7 @@ class TestEditChannel(unittest.TestCase):
def test_edit_channel_no_change(self):
self.verify_name_internal.return_value = None
kojihub.get_channel.return_value = self.channel_info
self.get_channel.return_value = self.channel_info
r = self.exports.editChannel(self.channel_name, description='description')
self.assertFalse(r)

View file

@ -10,9 +10,9 @@ import kojihub
class TestEditExternalRepo(unittest.TestCase):
def setUp(self):
self.get_external_repo = mock.patch('kojihub.get_external_repo').start()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.context').start()
self.get_external_repo = mock.patch('kojihub.kojihub.get_external_repo').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertPerm = mock.MagicMock()

View file

@ -23,20 +23,20 @@ class TestEditHost(unittest.TestCase):
def setUp(self):
self.diff = None
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context_db = mock.patch('koji.db.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context_db.session.assertLogin = mock.MagicMock()
self.context.session.assertPerm = mock.MagicMock()
self.exports = kojihub.RootExports()
self.get_host = mock.patch('kojihub.get_host').start()
self.get_host = mock.patch('kojihub.kojihub.get_host').start()
self.hostinfo = {
'id': 123,
'user_id': 234,
@ -52,49 +52,48 @@ class TestEditHost(unittest.TestCase):
mock.patch.stopall()
def test_edit_host_missing(self):
kojihub.get_host.side_effect = koji.GenericError
self.get_host.side_effect = koji.GenericError
with self.assertRaises(koji.GenericError):
self.exports.editHost('hostname')
kojihub.get_host.assert_called_once_with('hostname', strict=True)
self.get_host.assert_called_once_with('hostname', strict=True)
self.assertEqual(self.inserts, [])
self.assertEqual(self.updates, [])
def test_edit_host_invalid_description(self):
description = ['description']
kojihub.get_host.return_value = self.hostinfo
self.get_host.return_value = self.hostinfo
with self.assertRaises(koji.ParameterError) as ex:
self.exports.editHost('hostname', description=description)
self.assertEqual('Invalid type for description parameter: %s' % type(description),
str(ex.exception))
kojihub.get_host.assert_called_once_with('hostname', strict=True)
self.get_host.assert_called_once_with('hostname', strict=True)
self.assertEqual(self.inserts, [])
self.assertEqual(self.updates, [])
def test_edit_host_invalid_comment_parameter(self):
comment = ['comment']
kojihub.get_host.return_value = self.hostinfo
self.get_host.return_value = self.hostinfo
with self.assertRaises(koji.ParameterError) as ex:
self.exports.editHost('hostname', comment=comment)
self.assertEqual('Invalid type for comment parameter: %s' % type(comment),
str(ex.exception))
kojihub.get_host.assert_called_once_with('hostname', strict=True)
self.get_host.assert_called_once_with('hostname', strict=True)
self.assertEqual(self.inserts, [])
self.assertEqual(self.updates, [])
def test_edit_host_invalid_arches_parameter(self):
arches = ['arches arches']
kojihub.get_host.return_value = self.hostinfo
self.get_host.return_value = self.hostinfo
with self.assertRaises(koji.ParameterError) as ex:
self.exports.editHost('hostname', arches=arches)
self.assertEqual('Invalid type for arches parameter: %s' % type(arches),
str(ex.exception))
kojihub.get_host.assert_called_once_with('hostname', strict=True)
self.get_host.assert_called_once_with('hostname', strict=True)
self.assertEqual(self.inserts, [])
self.assertEqual(self.updates, [])
def test_edit_host_valid(self):
kojihub.get_host = mock.MagicMock()
kojihub.get_host.return_value = self.hostinfo
self.get_host.return_value = self.hostinfo
self.context_db.event_id = 42
self.context_db.session.user_id = 23
@ -102,11 +101,11 @@ class TestEditHost(unittest.TestCase):
comment='comment_new', non_existing_kw='bogus')
self.assertTrue(r)
kojihub.get_host.assert_called_once_with('hostname', strict=True)
self.get_host.assert_called_once_with('hostname', strict=True)
# revoke
self.assertEqual(len(self.updates), 1)
values = kojihub.get_host.return_value
values = self.get_host.return_value
clauses = ['host_id = %(id)i', 'active = TRUE']
revoke_data = {
'revoke_event': 42,
@ -139,15 +138,14 @@ class TestEditHost(unittest.TestCase):
self.assertEqual(insert.rawdata, rawdata)
def test_edit_host_no_change(self):
kojihub.get_host = mock.MagicMock()
kojihub.get_host.return_value = self.hostinfo
self.get_host.return_value = self.hostinfo
self.context_db.event_id = 42
self.context_db.session.user_id = 23
r = self.exports.editHost('hostname')
self.assertFalse(r)
kojihub.get_host.assert_called_once_with('hostname', strict=True)
self.get_host.assert_called_once_with('hostname', strict=True)
self.assertEqual(len(self.updates), 0)
self.assertEqual(len(self.inserts), 0)

View file

@ -12,10 +12,10 @@ UP = kojihub.UpdateProcessor
class TestEditPermission(unittest.TestCase):
def setUp(self):
self.lookup_perm = mock.patch('kojihub.lookup_perm').start()
self.update_processor = mock.patch('kojihub.UpdateProcessor').start()
self.lookup_perm = mock.patch('kojihub.kojihub.lookup_perm').start()
self.update_processor = mock.patch('kojihub.kojihub.UpdateProcessor').start()
self.exports = kojihub.RootExports()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertPerm = mock.MagicMock()

View file

@ -33,21 +33,21 @@ class TestEditTag(unittest.TestCase):
return query
def setUp(self):
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.get_tag = mock.patch('kojihub.get_tag').start()
self.get_perm_id = mock.patch('kojihub.get_perm_id').start()
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.context').start()
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
self.get_perm_id = mock.patch('kojihub.kojihub.get_perm_id').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context_db = mock.patch('koji.db.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context_db.session.assertLogin = mock.MagicMock()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.query_singleValue = mock.MagicMock()

View file

@ -8,11 +8,11 @@ import kojihub
class TestEditTagExternalRepo(unittest.TestCase):
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.session.assertPerm = mock.MagicMock()
self.get_tag = mock.patch('kojihub.get_tag').start()
self.get_external_repo = mock.patch('kojihub.get_external_repo').start()
self.get_tag_external_repos = mock.patch('kojihub.get_tag_external_repos').start()
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
self.get_external_repo = mock.patch('kojihub.kojihub.get_external_repo').start()
self.get_tag_external_repos = mock.patch('kojihub.kojihub.get_tag_external_repos').start()
self.get_tag.return_value = {'id': 1, 'name': 'tag'}
self.get_external_repo.return_value = {'id': 11, 'name': 'ext_repo'}
self.get_tag_external_repos.return_value = [{'external_repo_id': 11,
@ -22,8 +22,8 @@ class TestEditTagExternalRepo(unittest.TestCase):
'arches': 'x86_64 i686'}]
self.remove_external_repo_from_tag = mock.patch(
'kojihub.remove_external_repo_from_tag').start()
self.add_external_repo_to_tag = mock.patch('kojihub.add_external_repo_to_tag').start()
'kojihub.kojihub.remove_external_repo_from_tag').start()
self.add_external_repo_to_tag = mock.patch('kojihub.kojihub.add_external_repo_to_tag').start()
def tearDown(self):
mock.patch.stopall()

View file

@ -27,15 +27,15 @@ class TestEditUser(unittest.TestCase):
def setUp(self):
self.updates = []
self.get_user = mock.patch('kojihub.get_user').start()
self.verify_name_user = mock.patch('kojihub.verify_name_user').start()
self.context = mock.patch('kojihub.context').start()
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.verify_name_user = mock.patch('kojihub.kojihub.verify_name_user').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertLogin = mock.MagicMock()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.query_singleValue = mock.MagicMock()

View file

@ -18,8 +18,8 @@ class TestEnableChannel(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.get_channel = mock.patch('kojihub.get_channel').start()
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.get_channel = mock.patch('kojihub.kojihub.get_channel').start()
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.channelname = 'test-channel'

View file

@ -10,7 +10,7 @@ class TestEnableUser(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.get_user = mock.patch('kojihub.get_user').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
def test_non_exist_user(self):
username = 'test-user'

View file

@ -14,8 +14,8 @@ class TestEnsureVolumeSymlink(unittest.TestCase):
self.tempdir = tempfile.mkdtemp()
self.pathinfo = koji.PathInfo(self.tempdir)
mock.patch('koji.pathinfo', new=self.pathinfo).start()
mock.patch('kojihub.lookup_name', new=self.my_lookup_name).start()
self.check_volume_policy = mock.patch('kojihub.check_volume_policy',
mock.patch('kojihub.kojihub.lookup_name', new=self.my_lookup_name).start()
self.check_volume_policy = mock.patch('kojihub.kojihub.check_volume_policy',
return_value={'id':0, 'name': 'DEFAULT'}).start()
self.buildinfo = {
'id': 137,
@ -48,7 +48,7 @@ class TestEnsureVolumeSymlink(unittest.TestCase):
raise Exception('call created unexpected files')
del self.buildinfo['volume_name']
with mock.patch('kojihub.logger') as logger:
with mock.patch('kojihub.kojihub.logger') as logger:
kojihub.ensure_volume_symlink(self.buildinfo)
logger.warning.assert_called_once()

View file

@ -19,7 +19,7 @@ class TestFindBuildId(unittest.TestCase):
return query
def setUp(self):
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.query_singleValue = mock.MagicMock()

View file

@ -14,9 +14,9 @@ class TestGetRPM(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.context = mock.patch('kojihub.context').start()
self.get_external_repo_id = mock.patch('kojihub.get_external_repo_id').start()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.context = mock.patch('kojihub.kojihub.context').start()
self.get_external_repo_id = mock.patch('kojihub.kojihub.get_external_repo_id').start()
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
@ -99,10 +99,10 @@ class TestGetRPMHeaders(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.exports.getLoggedInUser = mock.MagicMock()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.cursor = mock.MagicMock()
self.get_rpm = mock.patch('kojihub.get_rpm').start()
self.get_build = mock.patch('kojihub.get_build').start()
self.get_rpm = mock.patch('kojihub.kojihub.get_rpm').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.get_header_fields = mock.patch('koji.get_header_fields').start()
self.tempdir = tempfile.mkdtemp()
self.pathinfo = koji.PathInfo(self.tempdir)

View file

@ -7,7 +7,7 @@ import kojihub
class TestGetRPMDeps(unittest.TestCase):
@mock.patch('kojihub.get_rpm')
@mock.patch('kojihub.kojihub.get_rpm')
def test_getRPMDeps_no_rpminfo(self, get_rpm):
def mock_get_rpm(rpmID, strict=False):
if strict:
@ -21,7 +21,7 @@ class TestGetRPMDeps(unittest.TestCase):
kojihub.RootExports().getRPMDeps(1, strict=True)
self.assertEqual(cm.exception.args[0], 'msg')
@mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': None})
@mock.patch('kojihub.kojihub.get_rpm', return_value={'id': 1, 'build_id': None})
def test_getRPMDeps_external_rpm(self, get_rpm):
re = kojihub.RootExports().getRPMDeps(1)
self.assertEqual(re, [])
@ -30,8 +30,8 @@ class TestGetRPMDeps(unittest.TestCase):
self.assertEqual(cm.exception.args[0],
'Can not get dependencies, because RPM: 1 is not internal')
@mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': 1})
@mock.patch('kojihub.get_build', return_value={'id': 1})
@mock.patch('kojihub.kojihub.get_rpm', return_value={'id': 1, 'build_id': 1})
@mock.patch('kojihub.kojihub.get_build', return_value={'id': 1})
@mock.patch('koji.pathinfo.build', return_value='fakebuildpath')
@mock.patch('koji.pathinfo.rpm', return_value='fakerpmrelpath')
@mock.patch('os.path.exists', return_value=False)
@ -42,8 +42,8 @@ class TestGetRPMDeps(unittest.TestCase):
kojihub.RootExports().getRPMDeps(1, strict=True)
self.assertEqual(cm.exception.args[0], "RPM file of 1 doesn't exist")
@mock.patch('kojihub.get_rpm')
@mock.patch('kojihub.get_build')
@mock.patch('kojihub.kojihub.get_rpm')
@mock.patch('kojihub.kojihub.get_build')
@mock.patch('koji.pathinfo')
def test_getRPMDeps(self, pi, build, rpm):
pi.build.return_value = os.path.join(os.path.dirname(__file__), '../test_lib/data/rpms')

View file

@ -10,7 +10,7 @@ import kojihub
class TestGetRPMFile(unittest.TestCase):
@mock.patch('kojihub.get_rpm')
@mock.patch('kojihub.kojihub.get_rpm')
def test_getRPMFile_no_rpminfo(self, get_rpm):
def mock_get_rpm(rpmID, strict=False):
if strict:
@ -25,7 +25,7 @@ class TestGetRPMFile(unittest.TestCase):
kojihub.RootExports().getRPMFile(1, 'filename', strict=True)
self.assertEqual(cm.exception.args[0], 'msg')
@mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': None})
@mock.patch('kojihub.kojihub.get_rpm', return_value={'id': 1, 'build_id': None})
def test_getRPMFile_external_rpm(self, get_rpm):
re = kojihub.RootExports().getRPMFile(1, 'filename')
self.assertEqual(re, {})
@ -34,8 +34,8 @@ class TestGetRPMFile(unittest.TestCase):
self.assertEqual(cm.exception.args[0],
'Can not get RPM file, because RPM: 1 is not internal')
@mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': 1})
@mock.patch('kojihub.get_build', return_value={'id': 1})
@mock.patch('kojihub.kojihub.get_rpm', return_value={'id': 1, 'build_id': 1})
@mock.patch('kojihub.kojihub.get_build', return_value={'id': 1})
@mock.patch('koji.pathinfo.build', return_value='fakebuildpath')
@mock.patch('koji.pathinfo.rpm', return_value='fakerpmrelpath')
@mock.patch('os.path.exists', return_value=False)
@ -46,8 +46,8 @@ class TestGetRPMFile(unittest.TestCase):
kojihub.RootExports().getRPMFile(1, 'filename', strict=True)
self.assertEqual(cm.exception.args[0], "RPM package file of 1 doesn't exist")
@mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': 1})
@mock.patch('kojihub.get_build')
@mock.patch('kojihub.kojihub.get_rpm', return_value={'id': 1, 'build_id': 1})
@mock.patch('kojihub.kojihub.get_build')
@mock.patch('koji.pathinfo')
def test_getRPMFile(self, pi, build, rpm):
pi.build.return_value = os.path.join(os.path.dirname(__file__),

View file

@ -11,7 +11,7 @@ QP = kojihub.QueryProcessor
class TestGetActiveRepos(unittest.TestCase):
def setUp(self):
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []

View file

@ -9,10 +9,10 @@ class TestGetArchive(unittest.TestCase):
def setUp(self):
self.maxDiff = None
self.list_archives = mock.patch('kojihub.list_archives').start()
self.get_maven_archive = mock.patch('kojihub.get_maven_archive').start()
self.get_win_archive = mock.patch('kojihub.get_win_archive').start()
self.get_image_archive = mock.patch('kojihub.get_image_archive').start()
self.list_archives = mock.patch('kojihub.kojihub.list_archives').start()
self.get_maven_archive = mock.patch('kojihub.kojihub.get_maven_archive').start()
self.get_win_archive = mock.patch('kojihub.kojihub.get_win_archive').start()
self.get_image_archive = mock.patch('kojihub.kojihub.get_image_archive').start()
def tearDown(self):
mock.patch.stopall()

View file

@ -16,7 +16,7 @@ EMPTY_FILES = []
class TestGetArchiveFile(unittest.TestCase):
@mock.patch('kojihub.list_archive_files')
@mock.patch('kojihub.kojihub.list_archive_files')
def test_simple(self, list_archive_files):
list_archive_files.return_value = FILES
@ -29,7 +29,7 @@ class TestGetArchiveFile(unittest.TestCase):
list_archive_files.assert_called_with(1, strict=True)
self.assertEqual(rv, FILES[0])
@mock.patch('kojihub.list_archive_files')
@mock.patch('kojihub.kojihub.list_archive_files')
def test_empty_files(self, list_archive_files):
list_archive_files.return_value = EMPTY_FILES
@ -45,7 +45,7 @@ class TestGetArchiveFile(unittest.TestCase):
list_archive_files.assert_called_with(1, strict=True)
self.assertEqual(cm.exception.args[0], 'error message')
@mock.patch('kojihub.list_archive_files')
@mock.patch('kojihub.kojihub.list_archive_files')
def test_non_existing_file(self, list_archive_files):
list_archive_files.return_value = FILES

View file

@ -9,7 +9,7 @@ class TestGetBuild(DBQueryTestCase):
def setUp(self):
super(TestGetBuild, self).setUp()
self.find_build_id = mock.patch('kojihub.find_build_id').start()
self.find_build_id = mock.patch('kojihub.kojihub.find_build_id').start()
def test_non_exist_build_string(self):
build = 'build-1-23'

View file

@ -6,8 +6,8 @@ import kojihub
class TestGetBuildConfig(unittest.TestCase):
@mock.patch('kojihub.readFullInheritance')
@mock.patch('kojihub.get_tag')
@mock.patch('kojihub.kojihub.readFullInheritance')
@mock.patch('kojihub.kojihub.get_tag')
def test_simple_tag(self, get_tag, readFullInheritance):
tag = 'tag_name'
get_tag.return_value = {'id': 123, 'name': tag, 'extra': {}}
@ -25,8 +25,8 @@ class TestGetBuildConfig(unittest.TestCase):
'config_inheritance': {'extra': {}, 'arches': None},
})
@mock.patch('kojihub.readFullInheritance')
@mock.patch('kojihub.get_tag')
@mock.patch('kojihub.kojihub.readFullInheritance')
@mock.patch('kojihub.kojihub.get_tag')
def test_basic_inherited(self, get_tag, readFullInheritance):
tag = 'tag_name'
get_tag.side_effect = [
@ -80,8 +80,8 @@ class TestGetBuildConfig(unittest.TestCase):
'name': 'tag_name'
})
@mock.patch('kojihub.readFullInheritance')
@mock.patch('kojihub.get_tag')
@mock.patch('kojihub.kojihub.readFullInheritance')
@mock.patch('kojihub.kojihub.get_tag')
def test_inherited_noconfig(self, get_tag, readFullInheritance):
tag = 'tag_name'
get_tag.side_effect = [

View file

@ -10,7 +10,7 @@ import kojihub
class TestGetBuildLogs(unittest.TestCase):
def setUp(self):
self.get_build = mock.patch('kojihub.get_build').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.pathinfo = mock.patch('koji.pathinfo').start()
self.tempdir = tempfile.mkdtemp()
koji.pathinfo.build_logs.return_value = self.tempdir
@ -36,10 +36,10 @@ class TestGetBuildLogs(unittest.TestCase):
def test_get_build_logs_basic(self):
files = [
'noarch/build.log',
'x86_64/build.log',
's390x/build.log',
]
'noarch/build.log',
'x86_64/build.log',
's390x/build.log',
]
files.sort()
self.make_tree(files)
data = kojihub.get_build_logs('fakebuild')
@ -58,25 +58,25 @@ class TestGetBuildLogs(unittest.TestCase):
fo.write('NOT A DIRECTORY\n')
koji.pathinfo.build_logs.return_value = fn
try:
data = kojihub.get_build_logs('fakebuild')
kojihub.get_build_logs('fakebuild')
raise Exception('Expected exception not raised')
except koji.GenericError as e:
self.assertEqual(e.args[0][:15], 'Not a directory')
def test_get_build_logs_emptydirs(self):
files = [
'./build.log',
'noarch/build.log',
'noarch/root.log',
'x86_64/build.log',
's390x/build.log',
'oddball/log/dir/fake.log',
]
'./build.log',
'noarch/build.log',
'noarch/root.log',
'x86_64/build.log',
's390x/build.log',
'oddball/log/dir/fake.log',
]
empty_dirs = [
'foo/bar/baz/',
'a/b/c/',
'empty/',
]
'foo/bar/baz/',
'a/b/c/',
'empty/',
]
files.sort()
self.make_tree(files + empty_dirs)
data = kojihub.get_build_logs('fakebuild')
@ -84,20 +84,20 @@ class TestGetBuildLogs(unittest.TestCase):
files2.sort()
self.assertEqual(files, files2)
@mock.patch('kojihub.logger')
@mock.patch('kojihub.kojihub.logger')
def test_get_build_logs_symlinks(self, logger):
# symlinks should be ignored with a warning
files = [
'noarch/build.log',
'noarch/root.log',
'noarch/mock.log',
'noarch/checkout.log',
'noarch/readme.txt',
'oddball/log/dir/fake.log',
]
'noarch/build.log',
'noarch/root.log',
'noarch/mock.log',
'noarch/checkout.log',
'noarch/readme.txt',
'oddball/log/dir/fake.log',
]
empty_dirs = [
'just_links/',
]
'just_links/',
]
files.sort()
self.make_tree(files + empty_dirs)
os.symlink('SOME/PATH', '%s/%s' % (self.tempdir, 'symlink.log'))
@ -109,18 +109,18 @@ class TestGetBuildLogs(unittest.TestCase):
self.assertEqual(files, files2)
self.assertEqual(logger.warning.call_count, 3)
@mock.patch('kojihub.logger')
@mock.patch('kojihub.kojihub.logger')
def test_get_build_logs_nonfile(self, logger):
# symlinks should be ignored
files = [
'noarch/build.log',
'noarch/root.log',
'noarch/mock.log',
'noarch/checkout.log',
'noarch/readme.txt',
'noarch/hello',
'oddball/log/dir/fake.log',
]
'noarch/build.log',
'noarch/root.log',
'noarch/mock.log',
'noarch/checkout.log',
'noarch/readme.txt',
'noarch/hello',
'oddball/log/dir/fake.log',
]
files.sort()
self.make_tree(files)
os.mkfifo('%s/%s' % (self.tempdir, 'this_is_a_named_pipe'))

View file

@ -7,7 +7,7 @@ import kojihub
class TestGetBuildNotification(unittest.TestCase):
def setUp(self):
self.QueryProcessor = mock.patch('kojihub.QueryProcessor').start()
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor').start()
self.query = self.QueryProcessor.return_value
self.exports = kojihub.RootExports()

View file

@ -7,7 +7,7 @@ import kojihub
class TestGetBuildNotificationBlock(unittest.TestCase):
def setUp(self):
self.QueryProcessor = mock.patch('kojihub.QueryProcessor').start()
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor').start()
self.query = self.QueryProcessor.return_value
self.exports = kojihub.RootExports()

View file

@ -7,9 +7,9 @@ import kojihub
class TestGetBuildNotificationBlocks(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.get_user = mock.patch('kojihub.get_user').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.get_build_notification_blocks = mock.patch(
'kojihub.get_build_notification_blocks').start()
'kojihub.kojihub.get_build_notification_blocks').start()
def tearDown(self):
mock.patch.stopall()

View file

@ -7,8 +7,8 @@ import kojihub
class TestGetBuildNotifications(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.get_user = mock.patch('kojihub.get_user').start()
self.get_build_notifications = mock.patch('kojihub.get_build_notifications').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.get_build_notifications = mock.patch('kojihub.kojihub.get_build_notifications').start()
def test_loggedin_user(self):
self.get_user.return_value = {'id': 1}

View file

@ -9,7 +9,7 @@ import kojihub
class TestGetBuildTarget(unittest.TestCase):
def setUp(self):
self.get_build_targets = mock.patch('kojihub.get_build_targets').start()
self.get_build_targets = mock.patch('kojihub.kojihub.get_build_targets').start()
self.exports = kojihub.RootExports()
self.build_target = 'build-target'

View file

@ -11,12 +11,12 @@ class TestGetBuildTargets(unittest.TestCase):
def setUp(self):
self.maxDiff = None
self.name_or_id_clause = mock.patch('kojihub.name_or_id_clause').start()
self.get_tag_id = mock.patch('kojihub.get_tag_id').start()
self.name_or_id_clause = mock.patch('kojihub.kojihub.name_or_id_clause').start()
self.get_tag_id = mock.patch('kojihub.kojihub.get_tag_id').start()
self.exports = kojihub.RootExports()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.cursor = mock.MagicMock()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.build_target = 'build-target'

View file

@ -10,14 +10,14 @@ class TestGetBuildType(unittest.TestCase):
def setUp(self):
self.maxDiff = None
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.query_execute = mock.MagicMock()
self.get_build = mock.patch('kojihub.get_build').start()
self.get_maven_build = mock.patch('kojihub.get_maven_build').start()
self.get_win_build = mock.patch('kojihub.get_win_build').start()
self.get_image_build = mock.patch('kojihub.get_image_build').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.get_maven_build = mock.patch('kojihub.kojihub.get_maven_build').start()
self.get_win_build = mock.patch('kojihub.kojihub.get_win_build').start()
self.get_image_build = mock.patch('kojihub.kojihub.get_image_build').start()
def tearDown(self):
mock.patch.stopall()

View file

@ -7,7 +7,7 @@ import kojihub
class TestGetBuildroot(unittest.TestCase):
def setUp(self):
self.query_buildroots = mock.patch('kojihub.query_buildroots').start()
self.query_buildroots = mock.patch('kojihub.kojihub.query_buildroots').start()
self.buildroot_id = 1
def test_empty_buildroots_without_strict(self):

View file

@ -12,8 +12,8 @@ class TestGetChangelogEntries(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.get_build = mock.patch('kojihub.get_build').start()
self.context = mock.patch('kojihub.context').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.cursor = mock.MagicMock()
self.os_path_exists = mock.patch('os.path.exists').start()

View file

@ -19,10 +19,10 @@ class TestGetChannel(unittest.TestCase):
return query
def setUp(self):
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.exports = kojihub.RootExports()
def tearDown(self):

View file

@ -9,7 +9,7 @@ import kojihub
class TestGetExternalRepo(unittest.TestCase):
def setUp(self):
self.get_external_repos = mock.patch('kojihub.get_external_repos').start()
self.get_external_repos = mock.patch('kojihub.kojihub.get_external_repos').start()
self.exports = kojihub.RootExports()
def test_non_exist_repo_with_strict(self):

View file

@ -9,7 +9,9 @@ import kojihub
class TestGetGroupMembers(unittest.TestCase):
def setUp(self):
self.get_user = mock.patch('kojihub.get_user').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.session.assertPerm = mock.MagicMock()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.exports = kojihub.RootExports()
def test_non_exist_group(self):

View file

@ -17,10 +17,10 @@ class TestSetHostEnabled(unittest.TestCase):
return query
def setUp(self):
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.exports = kojihub.RootExports()

View file

@ -17,7 +17,7 @@ class TestGetLastHostUpdate(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.query_singleValue = mock.MagicMock()

View file

@ -9,9 +9,9 @@ from psycopg2._psycopg import IntegrityError
class TestGetNextBuild(unittest.TestCase):
def setUp(self):
self.get_next_release = mock.patch('kojihub.get_next_release').start()
self.new_build = mock.patch('kojihub.new_build').start()
self._dml = mock.patch('kojihub._dml').start()
self.get_next_release = mock.patch('kojihub.kojihub.get_next_release').start()
self.new_build = mock.patch('kojihub.kojihub.new_build').start()
self._dml = mock.patch('kojihub.kojihub._dml').start()
self.binfo = {'name': 'name', 'version': 'version'}
def tearDown(self):

View file

@ -8,9 +8,9 @@ class TestGetNextRelease(unittest.TestCase):
def setUp(self):
self.maxDiff = None
self.QueryProcessor = mock.patch('kojihub.QueryProcessor').start()
self.get_build = mock.patch('kojihub.get_build').start()
self._dml = mock.patch('kojihub._dml').start()
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor').start()
self.get_build = mock.patch('kojihub.kojihub.get_build').start()
self._dml = mock.patch('kojihub.kojihub._dml').start()
self.query = self.QueryProcessor.return_value
self.binfo = {'name': 'name', 'version': 'version'}

View file

@ -29,23 +29,23 @@ class TestGetNotificationRecipients(unittest.TestCase):
return update
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.context.opts = {
'EmailDomain': 'test.domain.com',
'NotifyOnSuccess': True,
}
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.InsertProcessor = mock.patch('kojihub.InsertProcessor',
self.InsertProcessor = mock.patch('kojihub.kojihub.InsertProcessor',
side_effect=self.getInsert).start()
self.inserts = []
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
self.UpdateProcessor = mock.patch('kojihub.kojihub.UpdateProcessor',
side_effect=self.getUpdate).start()
self.updates = []
self.readPackageList = mock.patch('kojihub.readPackageList').start()
self.get_user = mock.patch('kojihub.get_user').start()
self.readPackageList = mock.patch('kojihub.kojihub.readPackageList').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.exports = kojihub.RootExports()

View file

@ -15,14 +15,14 @@ class TestGetSessionInfo(unittest.TestCase):
return query
def setUp(self):
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.exports = kojihub.RootExports()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.context.session.hasPerm = mock.MagicMock()
self.get_user = mock.patch('kojihub.get_user').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.userinfo = {'id': 123, 'name': 'testuser'}
self.exports.getLoggedInUser = mock.MagicMock()

View file

@ -11,12 +11,12 @@ class TestGetTagExternalRepos(unittest.TestCase):
def setUp(self):
self.maxDiff = None
self.get_tag = mock.patch('kojihub.get_tag').start()
self.get_external_repo = mock.patch('kojihub.get_external_repo').start()
self.get_tag = mock.patch('kojihub.kojihub.get_tag').start()
self.get_external_repo = mock.patch('kojihub.kojihub.get_external_repo').start()
self.exports = kojihub.RootExports()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
self.cursor = mock.MagicMock()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
self.build_tag = 'tag'

View file

@ -6,11 +6,12 @@ import kojihub
QP = kojihub.QueryProcessor
class TestGetTaskChildren(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
def getQuery(self, *args, **kwargs):

View file

@ -34,8 +34,8 @@ class TestGetUploadPath(unittest.TestCase):
with self.assertRaises(GenericError):
kojihub.get_upload_path(reldir='tasks/1/should_be_number', name='error', create=True)
@mock.patch('kojihub.context')
@mock.patch('kojihub.Host')
@mock.patch('kojihub.kojihub.context')
@mock.patch('kojihub.kojihub.Host')
def test_get_upload_path_invalid_upload_dir_owner(self, host, context):
cursor = mock.MagicMock()
context.cnx.cursor.return_value = cursor
@ -49,7 +49,7 @@ class TestGetUploadPath(unittest.TestCase):
with self.assertRaises(GenericError):
kojihub.get_upload_path(reldir=reldir, name='error', create=True)
@mock.patch('kojihub.Host')
@mock.patch('kojihub.kojihub.Host')
def test_get_upload_path_invalid_upload_no_dir_owner(self, host):
dir = kojihub.get_upload_path(reldir='tasks/1/1', name='error', create=False)
assert dir == '%s/work/tasks/1/1/error' % self.topdir

View file

@ -12,8 +12,8 @@ class TestGetUser(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.context = mock.patch('kojihub.context').start()
self.QueryProcessor = mock.patch('kojihub.QueryProcessor',
self.context = mock.patch('kojihub.kojihub.context').start()
self.QueryProcessor = mock.patch('kojihub.kojihub.QueryProcessor',
side_effect=self.getQuery).start()
self.queries = []
@ -89,7 +89,7 @@ class TestGetUser(unittest.TestCase):
class TestGetUserByKrbPrincipal(unittest.TestCase):
def setUp(self):
self.get_user = mock.patch('kojihub.get_user').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
def test_wrong_type_krb_principal(self):
krb_principal = ['test-user']

View file

@ -6,7 +6,7 @@ import kojihub
class TestGetUserPerms(unittest.TestCase):
def setUp(self):
self.get_user = mock.patch('kojihub.get_user').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.get_user_perms = mock.patch('koji.auth.get_user_perms').start()
def tearDown(self):

View file

@ -9,7 +9,7 @@ class TestGetVolume(unittest.TestCase):
def setUp(self):
self.exports = kojihub.RootExports()
self.lookup_name = mock.patch('kojihub.lookup_name').start()
self.lookup_name = mock.patch('kojihub.kojihub.lookup_name').start()
def test_non_exist_volume_with_strict(self):
volume = ['test-volume']

View file

@ -13,14 +13,14 @@ UP = kojihub.UpdateProcessor
class TestGrantPermission(unittest.TestCase):
def setUp(self):
self.verify_name_internal = mock.patch('kojihub.verify_name_internal').start()
self.get_user = mock.patch('kojihub.get_user').start()
self.lookup_perm = mock.patch('kojihub.lookup_perm').start()
self.insert_processor = mock.patch('kojihub.InsertProcessor').start()
self.update_processor = mock.patch('kojihub.UpdateProcessor').start()
self.verify_name_internal = mock.patch('kojihub.kojihub.verify_name_internal').start()
self.get_user = mock.patch('kojihub.kojihub.get_user').start()
self.lookup_perm = mock.patch('kojihub.kojihub.lookup_perm').start()
self.insert_processor = mock.patch('kojihub.kojihub.InsertProcessor').start()
self.update_processor = mock.patch('kojihub.kojihub.UpdateProcessor').start()
self.get_user_perms = mock.patch('koji.auth.get_user_perms').start()
self.exports = kojihub.RootExports()
self.context = mock.patch('kojihub.context').start()
self.context = mock.patch('kojihub.kojihub.context').start()
# It seems MagicMock will not automatically handle attributes that
# start with "assert"
self.context.session.assertPerm = mock.MagicMock()

Some files were not shown because too many files have changed in this diff Show more