Use unittest2 for rhel6 compatibility
Fixes: https://pagure.io/koji/issue/830
This commit is contained in:
parent
c633188bec
commit
c68396c059
162 changed files with 1152 additions and 537 deletions
|
|
@ -131,7 +131,7 @@ def parse_task_params(method, params):
|
|||
break
|
||||
except koji.ParameterError as e:
|
||||
if not err:
|
||||
err = e.message
|
||||
err = e.args[0]
|
||||
else:
|
||||
raise koji.ParameterError("Invalid signature for %s: %s" % (method, err))
|
||||
|
||||
|
|
|
|||
|
|
@ -251,39 +251,38 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
self.logger.info('New runroot')
|
||||
self.logger.info("Runroot mounts: %s" % mounts)
|
||||
fn = '%s/tmp/runroot_mounts' % rootdir
|
||||
fslog = open(fn, 'a')
|
||||
logfile = "%s/do_mounts.log" % self.workdir
|
||||
uploadpath = self.getUploadDir()
|
||||
error = None
|
||||
for dev, path, type, opts in mounts:
|
||||
if not path.startswith('/'):
|
||||
raise koji.GenericError("invalid mount point: %s" % path)
|
||||
mpoint = "%s%s" % (rootdir, path)
|
||||
if opts is None:
|
||||
opts = []
|
||||
else:
|
||||
opts = opts.split(',')
|
||||
if 'bind' in opts:
|
||||
#make sure dir exists
|
||||
if not os.path.isdir(dev):
|
||||
error = koji.GenericError("No such directory or mount: %s" % dev)
|
||||
with open(fn, 'a') as fslog:
|
||||
logfile = "%s/do_mounts.log" % self.workdir
|
||||
uploadpath = self.getUploadDir()
|
||||
error = None
|
||||
for dev, path, type, opts in mounts:
|
||||
if not path.startswith('/'):
|
||||
raise koji.GenericError("invalid mount point: %s" % path)
|
||||
mpoint = "%s%s" % (rootdir, path)
|
||||
if opts is None:
|
||||
opts = []
|
||||
else:
|
||||
opts = opts.split(',')
|
||||
if 'bind' in opts:
|
||||
#make sure dir exists
|
||||
if not os.path.isdir(dev):
|
||||
error = koji.GenericError("No such directory or mount: %s" % dev)
|
||||
break
|
||||
type = 'none'
|
||||
if 'bg' in opts:
|
||||
error = koji.GenericError("bad config: background mount not allowed")
|
||||
break
|
||||
type = 'none'
|
||||
if 'bg' in opts:
|
||||
error = koji.GenericError("bad config: background mount not allowed")
|
||||
break
|
||||
opts = ','.join(opts)
|
||||
cmd = ['mount', '-t', type, '-o', opts, dev, mpoint]
|
||||
self.logger.info("Mount command: %r" % cmd)
|
||||
koji.ensuredir(mpoint)
|
||||
status = log_output(self.session, cmd[0], cmd, logfile, uploadpath, logerror=True, append=True)
|
||||
if not isSuccess(status):
|
||||
error = koji.GenericError("Unable to mount %s: %s" \
|
||||
% (mpoint, parseStatus(status, cmd)))
|
||||
break
|
||||
fslog.write("%s\n" % mpoint)
|
||||
fslog.flush()
|
||||
fslog.close()
|
||||
opts = ','.join(opts)
|
||||
cmd = ['mount', '-t', type, '-o', opts, dev, mpoint]
|
||||
self.logger.info("Mount command: %r" % cmd)
|
||||
koji.ensuredir(mpoint)
|
||||
status = log_output(self.session, cmd[0], cmd, logfile, uploadpath, logerror=True, append=True)
|
||||
if not isSuccess(status):
|
||||
error = koji.GenericError("Unable to mount %s: %s" \
|
||||
% (mpoint, parseStatus(status, cmd)))
|
||||
break
|
||||
fslog.write("%s\n" % mpoint)
|
||||
fslog.flush()
|
||||
if error is not None:
|
||||
self.undo_mounts(rootdir, fatal=False)
|
||||
raise error
|
||||
|
|
@ -293,10 +292,9 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
mounts = set()
|
||||
fn = '%s/tmp/runroot_mounts' % rootdir
|
||||
if os.path.exists(fn):
|
||||
fslog = open(fn, 'r')
|
||||
for line in fslog.readlines():
|
||||
mounts.add(line.strip())
|
||||
fslog.close()
|
||||
with open(fn, 'r') as fslog:
|
||||
for line in fslog.readlines():
|
||||
mounts.add(line.strip())
|
||||
#also, check /proc/mounts just in case
|
||||
mounts |= set(scan_mounts(rootdir))
|
||||
mounts = sorted(mounts)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ import mock
|
|||
import os
|
||||
import smtplib
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import koji
|
||||
import koji.util
|
||||
from .loadkojid import kojid
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@ import unittest
|
|||
import mock
|
||||
import rpm
|
||||
import tempfile
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import koji
|
||||
|
||||
from .loadkojid import kojid
|
||||
from six.moves import range
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import inspect
|
||||
import mock
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import koji
|
||||
import koji.tasks
|
||||
|
||||
|
|
|
|||
30
tests/test_cli/data/image-build-config.conf
Normal file
30
tests/test_cli/data/image-build-config.conf
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
[image-build]
|
||||
name = fedora-server-docker
|
||||
version = 26
|
||||
target = f26-candidate
|
||||
install_tree = https://alt.fedoraproject.org/pub/alt/releases/26/Cloud/$arch/os/
|
||||
arches = x86_64,ppc,arm64
|
||||
can_fail=ppc,arm64
|
||||
|
||||
format = qcow2,rhevm-ova,vsphere-ova
|
||||
distro = Fedora-26
|
||||
repo = https://alt.fedoraproject.org/pub/alt/releases/26/Cloud/$arch/os/
|
||||
disk_size = 20
|
||||
|
||||
ksversion = DEVEL
|
||||
kickstart = fedora-26-server-docker.ks
|
||||
ksurl = git://git.fedorahosted.org/git/spin-kickstarts.git?fedora26#68c40eb7
|
||||
specfile = git://git.fedorahosted.org/git/spin-kickstarts.git?spec_templates/fedora26#68c40eb7
|
||||
|
||||
[ova-options]
|
||||
vsphere_product_version=26
|
||||
rhevm_description=Fedora Cloud 26
|
||||
vsphere_product_vendor_name=Fedora Project
|
||||
ovf_memory_mb=6144
|
||||
rhevm_default_display_type=1
|
||||
vsphere_product_name=Fedora Cloud 26
|
||||
ovf_cpu_count=4
|
||||
rhevm_os_descriptor=Fedora-26
|
||||
|
||||
[factory-parameters]
|
||||
factory_test_ver=1.0
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
import mock
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.lib import activate_session
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
|
||||
import mock
|
||||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_add_group
|
||||
|
||||
|
|
@ -108,7 +109,10 @@ class TestAddGroup(unittest.TestCase):
|
|||
session.getTag.assert_not_called()
|
||||
session.getTagGroups.assert_not_called()
|
||||
session.groupListAdd.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_add_group_pkg
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_add_group_req
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_add_host
|
||||
|
||||
|
|
@ -125,7 +128,10 @@ class TestAddHost(unittest.TestCase):
|
|||
activate_session_mock.assert_not_called()
|
||||
session.hasHost.assert_not_called()
|
||||
session.addHost.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_add_host_to_channel
|
||||
|
||||
|
|
@ -193,7 +196,10 @@ class TestAddHostToChannel(unittest.TestCase):
|
|||
session.getChannel.assert_not_called()
|
||||
session.listChannels.assert_not_called()
|
||||
session.addHostToChannel.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import koji
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
from six.moves import StringIO
|
||||
|
||||
from koji_cli.commands import handle_add_notification
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import call
|
||||
|
||||
|
|
@ -172,7 +175,10 @@ class TestAddPkg(unittest.TestCase):
|
|||
self.assertEqual(session.mock_calls,
|
||||
[call.getUser(owner),
|
||||
call.getTag(tag)])
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 1)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
|
|
@ -210,7 +216,10 @@ class TestAddPkg(unittest.TestCase):
|
|||
session.getTag.assert_not_called()
|
||||
session.listPackages.assert_not_called()
|
||||
session.packageListAdd.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
|
|
@ -244,7 +253,10 @@ class TestAddPkg(unittest.TestCase):
|
|||
session.getTag.assert_not_called()
|
||||
session.listPackages.assert_not_called()
|
||||
session.packageListAdd.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_add_tag
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_add_user
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_add_volume
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
import koji
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
from koji_cli.commands import handle_assign_task
|
||||
|
||||
|
||||
|
|
@ -102,7 +105,10 @@ class TestAssignTask(unittest.TestCase):
|
|||
activate_session_mock.assert_not_called()
|
||||
session.hasHost.assert_not_called()
|
||||
session.addHost.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_block_group_pkg
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_block_group_req
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import call
|
||||
|
||||
|
|
@ -178,7 +181,10 @@ class TestBlockPkg(unittest.TestCase):
|
|||
session.getTag.assert_not_called()
|
||||
session.listPackages.assert_not_called()
|
||||
session.packageListBlock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_build, _progress_callback
|
||||
|
||||
|
|
@ -162,7 +165,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
self.session.build.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
|
|
@ -218,7 +224,10 @@ Options:
|
|||
self.session.build.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 0)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
|
|
@ -264,7 +273,10 @@ Options:
|
|||
self.session.build.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -354,7 +366,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
self.session.build.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -402,7 +417,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
self.session.build.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -450,7 +468,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
self.session.build.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import json
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import json
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_call
|
||||
from . import utils
|
||||
|
|
@ -118,13 +121,16 @@ class TestCall(utils.CliTestCase):
|
|||
}
|
||||
|
||||
for mod, msg in module.items():
|
||||
with mock.patch('koji_cli.commands.%s' % mod, new=None), \
|
||||
self.assertRaises(SystemExit) as cm:
|
||||
handle_call(options, session, arguments)
|
||||
with mock.patch('koji_cli.commands.%s' % mod, new=None):
|
||||
with self.assertRaises(SystemExit) as cm:
|
||||
handle_call(options, session, arguments)
|
||||
expected = self.format_error_message(msg)
|
||||
self.assert_console_message(stderr, expected)
|
||||
activate_session_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
def test_handle_call_help(self):
|
||||
"""Test handle_call help message"""
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_chain_build
|
||||
|
||||
|
|
@ -119,7 +122,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
self.session.chainBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
|
|
@ -163,7 +169,10 @@ Options:
|
|||
self.session.chainBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 0)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -212,7 +221,10 @@ Options:
|
|||
self.session.chainBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -271,7 +283,10 @@ Options:
|
|||
self.session.chainBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -453,7 +468,10 @@ Target target is not usable for a chain-build
|
|||
If there are no dependencies, use the build command instead
|
||||
""" % (progname, progname)
|
||||
self.assertMultiLineEqual(actual, expected)
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import call
|
||||
from koji_cli.commands import handle_disable_host
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_disable_user
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
import copy
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import copy
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
|
||||
from koji_cli.commands import handle_dist_repo
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import mock
|
|||
import six
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.lib import download_file, _download_progress
|
||||
|
||||
|
|
@ -45,7 +48,11 @@ class TestDownloadFile(unittest.TestCase):
|
|||
actual = self.stdout.getvalue()
|
||||
expected = 'Downloading: %s\n' % self.tempdir
|
||||
self.assertMultiLineEqual(actual, expected)
|
||||
self.assertEqual(cm.exception.args, (21, 'Is a directory'))
|
||||
if isinstance(cm.exception, tuple):
|
||||
self.assertEqual(cm.exception[0], 21)
|
||||
self.assertEqual(cm.exception[1], 'Is a directory')
|
||||
else:
|
||||
self.assertEqual(cm.exception.args, (21, 'Is a directory'))
|
||||
self.requests_get.assert_called_once()
|
||||
|
||||
@mock_open()
|
||||
|
|
|
|||
|
|
@ -88,7 +88,11 @@ class TestDownloadLogs(utils.CliTestCase):
|
|||
out_file = six.StringIO()
|
||||
self.custom_open['kojilogs/x86_64-123456/volume1/file1.log'] = out_file
|
||||
|
||||
with mock.patch('koji_cli.commands.open', new=self.mock_builtin_open):
|
||||
if six.PY2:
|
||||
target = '__builtin__.open'
|
||||
else:
|
||||
target = 'builtins.open'
|
||||
with mock.patch(target, new=self.mock_builtin_open):
|
||||
anon_handle_download_logs(self.options, self.session, [str(task_id)])
|
||||
|
||||
self.session.getTaskInfo.assert_called_once_with(task_id)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ from mock import call
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import anon_handle_download_task
|
||||
|
||||
|
|
@ -204,7 +207,10 @@ class TestDownloadTask(unittest.TestCase):
|
|||
self.session.getTaskChildren.assert_not_called()
|
||||
self.list_task_output_all_volumes.assert_called_once_with(self.session, task_id)
|
||||
self.download_file.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 1)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
|
||||
def test_handle_download_parent_not_finished(self):
|
||||
task_id = 123333
|
||||
|
|
@ -237,7 +243,10 @@ class TestDownloadTask(unittest.TestCase):
|
|||
self.session.getTaskChildren.assert_not_called()
|
||||
self.list_task_output_all_volumes.assert_called_once_with(self.session, task_id)
|
||||
self.download_file.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 1)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
|
||||
def test_handle_download_child_not_finished(self):
|
||||
task_id = 123333
|
||||
|
|
@ -268,7 +277,10 @@ class TestDownloadTask(unittest.TestCase):
|
|||
self.session.getTaskChildren.assert_called_once_with(task_id)
|
||||
self.list_task_output_all_volumes.assert_called_once_with(self.session, 22222)
|
||||
self.download_file.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 1)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
|
||||
def test_handle_download_invalid_file_name(self):
|
||||
task_id = 123333
|
||||
|
|
@ -295,7 +307,10 @@ class TestDownloadTask(unittest.TestCase):
|
|||
self.session.getTaskChildren.assert_not_called()
|
||||
self.list_task_output_all_volumes.assert_called_once_with(self.session, task_id)
|
||||
self.download_file.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 1)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 1)
|
||||
|
||||
def test_handle_download_help(self):
|
||||
args = ['--help']
|
||||
|
|
@ -321,7 +336,10 @@ Options:
|
|||
actual = self.stderr.getvalue()
|
||||
expected = ''
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 0)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
|
||||
def test_handle_download_no_task_id(self):
|
||||
args = []
|
||||
|
|
@ -340,7 +358,10 @@ Options:
|
|||
%s: error: Please specify a task ID
|
||||
""" % (progname, progname)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
def test_handle_download_multi_task_id(self):
|
||||
args = ["123", "456"]
|
||||
|
|
@ -359,7 +380,10 @@ Options:
|
|||
%s: error: Only one task ID may be specified
|
||||
""" % (progname, progname)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import call
|
||||
|
||||
from koji_cli.commands import handle_edit_host
|
||||
|
|
@ -171,7 +175,10 @@ class TestEditHost(unittest.TestCase):
|
|||
session.getHost.assert_not_called()
|
||||
session.editHost.assert_not_called()
|
||||
session.multiCall.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import koji
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
from six.moves import StringIO
|
||||
|
||||
from koji_cli.commands import handle_edit_notification
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_edit_tag
|
||||
|
||||
|
|
@ -137,7 +139,10 @@ Options:
|
|||
# Finally, assert that things were called as we expected.
|
||||
activate_session_mock.assert_not_called()
|
||||
session.editTag2.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
|
|
@ -167,7 +172,10 @@ Options:
|
|||
# Finally, assert that things were called as we expected.
|
||||
activate_session_mock.assert_not_called()
|
||||
session.editTag2.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import call
|
||||
from koji_cli.commands import handle_enable_host
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_enable_user
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_grant_cg_access
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_grant_permission
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import koji
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
from koji_cli.commands import handle_moshimoshi, _printable_unicode
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -2,16 +2,20 @@ from __future__ import absolute_import
|
|||
import mock
|
||||
import six
|
||||
import os
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
|
||||
from koji_cli.commands import handle_image_build, _build_image_oz
|
||||
from . import utils
|
||||
|
||||
ConfigParser = six.moves.configparser.ConfigParser
|
||||
|
||||
TASK_OPTIONS = {
|
||||
"background": None,
|
||||
"config": "build-image-config.conf",
|
||||
"disk_size": "20",
|
||||
"distro": "Fedora-26",
|
||||
"factory_parameter": [
|
||||
|
|
@ -53,6 +57,13 @@ TASK_OPTIONS = {
|
|||
"wait": None,
|
||||
}
|
||||
|
||||
def mock_open():
|
||||
"""Return the right patch decorator for open"""
|
||||
if six.PY2:
|
||||
return mock.patch('__builtin__.open')
|
||||
else:
|
||||
return mock.patch('builtins.open')
|
||||
|
||||
|
||||
class Options(object):
|
||||
def __init__(self, init_dict):
|
||||
|
|
@ -208,30 +219,10 @@ class TestImageBuild(utils.CliTestCase):
|
|||
# Show long diffs in error output...
|
||||
maxDiff = None
|
||||
|
||||
def mock_os_path_exists(self, filepath):
|
||||
if filepath in self.custom_os_path_exists:
|
||||
return self.custom_os_path_exists[filepath]
|
||||
return self.os_path_exists(filepath)
|
||||
|
||||
def mock_builtin_open(self, filepath, *args):
|
||||
if filepath in self.custom_open:
|
||||
return self.custom_open[filepath]
|
||||
return self.builtin_open(filepath, *args)
|
||||
|
||||
def setUp(self):
|
||||
self.os_path_exists = os.path.exists
|
||||
self.custom_os_path_exists = {}
|
||||
|
||||
self.builtin_open = None
|
||||
if six.PY2:
|
||||
self.builtin_open = __builtins__['open']
|
||||
else:
|
||||
import builtins
|
||||
self.builtin_open = builtins.open
|
||||
self.custom_open = {}
|
||||
|
||||
self.options = mock.MagicMock()
|
||||
self.session = mock.MagicMock()
|
||||
self.configparser = mock.patch('six.moves.configparser.ConfigParser').start()
|
||||
|
||||
self.error_format = """Usage: %s image-build [options] <name> <version> <target> <install-tree-url> <arch> [<arch>...]
|
||||
%s image-build --config FILE
|
||||
|
|
@ -241,80 +232,43 @@ class TestImageBuild(utils.CliTestCase):
|
|||
%s: error: {message}
|
||||
""" % (self.progname, self.progname, self.progname)
|
||||
|
||||
def tearDown(self):
|
||||
mock.patch.stopall()
|
||||
|
||||
@mock.patch('koji_cli.commands._build_image_oz')
|
||||
def test_handle_image_build_with_config(self, build_image_oz_mock):
|
||||
"""Test handle_image_build argument with --config cases"""
|
||||
|
||||
# Case 1, config file not exist case
|
||||
config_file = "build-image-config.conf"
|
||||
expected = "%s not found!" % config_file
|
||||
|
||||
self.assert_system_exit(
|
||||
handle_image_build,
|
||||
self.options,
|
||||
self.session,
|
||||
['--config', config_file],
|
||||
stderr=self.format_error_message(expected),
|
||||
['--config', '/nonexistent-file-755684354'],
|
||||
stderr=self.format_error_message('/nonexistent-file-755684354 not found!'),
|
||||
activate_session=None)
|
||||
|
||||
# Case 2, no image-build section in config file
|
||||
self.custom_os_path_exists[config_file] = True
|
||||
self.custom_open[config_file] = six.StringIO('')
|
||||
|
||||
expected = "single section called [%s] is required" % "image-build"
|
||||
|
||||
with mock.patch('os.path.exists', new=self.mock_os_path_exists), \
|
||||
mock.patch('koji_cli.commands.open', new=self.mock_builtin_open):
|
||||
self.assert_system_exit(
|
||||
handle_image_build,
|
||||
self.options,
|
||||
self.session,
|
||||
['--config', config_file],
|
||||
stderr=self.format_error_message(expected),
|
||||
activate_session=None)
|
||||
self.configparser.return_value = ConfigParser()
|
||||
self.assert_system_exit(
|
||||
handle_image_build,
|
||||
self.options,
|
||||
self.session,
|
||||
['--config', '/dev/null'],
|
||||
stderr=self.format_error_message(expected),
|
||||
activate_session=None)
|
||||
|
||||
fake_config = """
|
||||
[image-build]
|
||||
name = fedora-server-docker
|
||||
version = 26
|
||||
target = f26-candidate
|
||||
install_tree = https://alt.fedoraproject.org/pub/alt/releases/26/Cloud/$arch/os/
|
||||
arches = x86_64,ppc,arm64
|
||||
can_fail=ppc,arm64
|
||||
|
||||
format = qcow2,rhevm-ova,vsphere-ova
|
||||
distro = Fedora-26
|
||||
repo = https://alt.fedoraproject.org/pub/alt/releases/26/Cloud/$arch/os/
|
||||
disk_size = 20
|
||||
|
||||
ksversion = DEVEL
|
||||
kickstart = fedora-26-server-docker.ks
|
||||
ksurl = git://git.fedorahosted.org/git/spin-kickstarts.git?fedora26#68c40eb7
|
||||
specfile = git://git.fedorahosted.org/git/spin-kickstarts.git?spec_templates/fedora26#68c40eb7
|
||||
|
||||
[ova-options]
|
||||
vsphere_product_version=26
|
||||
rhevm_description=Fedora Cloud 26
|
||||
vsphere_product_vendor_name=Fedora Project
|
||||
ovf_memory_mb=6144
|
||||
rhevm_default_display_type=1
|
||||
vsphere_product_name=Fedora Cloud 26
|
||||
ovf_cpu_count=4
|
||||
rhevm_os_descriptor=Fedora-26
|
||||
|
||||
[factory-parameters]
|
||||
factory_test_ver=1.0
|
||||
"""
|
||||
self.custom_open[config_file] = six.StringIO(fake_config)
|
||||
|
||||
with mock.patch('os.path.exists', new=self.mock_os_path_exists), \
|
||||
mock.patch('koji_cli.commands.open', new=self.mock_builtin_open):
|
||||
handle_image_build(
|
||||
self.options,
|
||||
self.session,
|
||||
['--config', config_file])
|
||||
config_file = os.path.join(os.path.dirname(__file__), 'data/image-build-config.conf')
|
||||
handle_image_build(
|
||||
self.options,
|
||||
self.session,
|
||||
['--config', config_file])
|
||||
|
||||
args, kwargs = build_image_oz_mock.call_args
|
||||
TASK_OPTIONS['config'] = config_file
|
||||
self.assertDictEqual(TASK_OPTIONS, args[1].__dict__)
|
||||
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
|
||||
from koji_cli.commands import handle_image_build_indirection, _build_image_indirection
|
||||
|
|
@ -145,10 +149,10 @@ class TestBuildImageIndirection(utils.CliTestCase):
|
|||
setattr(self.task_opts, r, None)
|
||||
expected = "Missing the following required options: "
|
||||
expected += "--" + r.replace('_', '-') + "\n"
|
||||
with self.assertRaises(koji.GenericError) as cm, \
|
||||
mock.patch('sys.stdout', new_callable=six.StringIO) as stdout:
|
||||
_build_image_indirection(
|
||||
self.options, self.task_opts, self.session, [])
|
||||
with self.assertRaises(koji.GenericError) as cm:
|
||||
with mock.patch('sys.stdout', new_callable=six.StringIO) as stdout:
|
||||
_build_image_indirection(
|
||||
self.options, self.task_opts, self.session, [])
|
||||
self.assert_console_message(stdout, expected)
|
||||
self.assertEqual(
|
||||
str(cm.exception), "Missing required options specified above")
|
||||
|
|
|
|||
|
|
@ -1,13 +1,21 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import koji
|
||||
import os
|
||||
import six
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
from koji_cli.commands import handle_import
|
||||
from . import utils
|
||||
|
||||
def md5_to_bytes(s):
|
||||
if six.PY2:
|
||||
return bytearray.fromhex(unicode(s))
|
||||
else:
|
||||
return bytearray.fromhex(s)
|
||||
|
||||
class TestImport(utils.CliTestCase):
|
||||
|
||||
|
|
@ -46,7 +54,7 @@ class TestImport(utils.CliTestCase):
|
|||
self.srpm_header = {
|
||||
'sourcepackage': 1,
|
||||
'name': 'bash',
|
||||
'sigmd5': bytearray.fromhex(self.md5),
|
||||
'sigmd5': md5_to_bytes(self.md5),
|
||||
'epoch': None,
|
||||
'version': '4.4.12',
|
||||
'release': '5.fc26',
|
||||
|
|
@ -57,7 +65,7 @@ class TestImport(utils.CliTestCase):
|
|||
self.rpm_header = {
|
||||
'sourcepackage': None,
|
||||
'name': 'bash',
|
||||
'sigmd5': bytearray.fromhex(self.md5),
|
||||
'sigmd5': md5_to_bytes(self.md5),
|
||||
'epoch': None,
|
||||
'version': '4.4.12',
|
||||
'release': '5.fc26',
|
||||
|
|
@ -86,14 +94,14 @@ class TestImport(utils.CliTestCase):
|
|||
fake_srv_path = kwargs.get('srv_path', '/path/to/server/import')
|
||||
upload_rpm_mock = kwargs.get('upload_rpm_mock', session.uploadWrapper)
|
||||
|
||||
with mock.patch('koji.get_header_fields') as get_header_fields_mock, \
|
||||
mock.patch('koji_cli.commands._unique_path') as unique_path_mock, \
|
||||
mock.patch('koji_cli.commands.activate_session') as activate_session_mock, \
|
||||
mock.patch('sys.stdout', new_callable=six.StringIO) as stdout, \
|
||||
upload_rpm_mock:
|
||||
get_header_fields_mock.return_value = rpm_header
|
||||
unique_path_mock.return_value = fake_srv_path
|
||||
handle_import(options, session, arguments)
|
||||
with mock.patch('koji.get_header_fields') as get_header_fields_mock:
|
||||
with mock.patch('koji_cli.commands._unique_path') as unique_path_mock:
|
||||
with mock.patch('koji_cli.commands.activate_session') as activate_session_mock:
|
||||
with mock.patch('sys.stdout', new_callable=six.StringIO) as stdout:
|
||||
with upload_rpm_mock:
|
||||
get_header_fields_mock.return_value = rpm_header
|
||||
unique_path_mock.return_value = fake_srv_path
|
||||
handle_import(options, session, arguments)
|
||||
|
||||
# check output message
|
||||
self.assert_console_message(stdout, expected)
|
||||
|
|
@ -128,11 +136,11 @@ class TestImport(utils.CliTestCase):
|
|||
expected = kwargs.get('expected', None)
|
||||
rpm_header = kwargs.get('rpm_header', {})
|
||||
|
||||
with mock.patch('koji.get_header_fields') as get_header_fields_mock, \
|
||||
mock.patch('koji_cli.commands.activate_session') as activate_session_mock, \
|
||||
mock.patch('sys.stdout', new_callable=six.StringIO) as stdout:
|
||||
get_header_fields_mock.return_value = rpm_header
|
||||
handle_import(options, session, arguments)
|
||||
with mock.patch('koji.get_header_fields') as get_header_fields_mock:
|
||||
with mock.patch('koji_cli.commands.activate_session') as activate_session_mock:
|
||||
with mock.patch('sys.stdout', new_callable=six.StringIO) as stdout:
|
||||
get_header_fields_mock.return_value = rpm_header
|
||||
handle_import(options, session, arguments)
|
||||
|
||||
# check output message
|
||||
self.assert_console_message(stdout, expected)
|
||||
|
|
@ -300,11 +308,11 @@ class TestImport(utils.CliTestCase):
|
|||
'payloadhash': self.md5
|
||||
}
|
||||
expected = "Build %s state is %s. Skipping import\n" % (nvr, 'FAILED')
|
||||
with mock.patch('koji.get_header_fields') as get_header_fields_mock, \
|
||||
mock.patch('koji_cli.commands.activate_session') as activate_session_mock, \
|
||||
mock.patch('sys.stdout', new_callable=six.StringIO) as stdout:
|
||||
get_header_fields_mock.return_value = self.srpm_header
|
||||
handle_import(options, session, arguments)
|
||||
with mock.patch('koji.get_header_fields') as get_header_fields_mock:
|
||||
with mock.patch('koji_cli.commands.activate_session') as activate_session_mock:
|
||||
with mock.patch('sys.stdout', new_callable=six.StringIO) as stdout:
|
||||
get_header_fields_mock.return_value = self.srpm_header
|
||||
handle_import(options, session, arguments)
|
||||
activate_session_mock.assert_called_with(session, options)
|
||||
self.assert_console_message(stdout, expected)
|
||||
|
||||
|
|
|
|||
|
|
@ -174,32 +174,32 @@ class TestImportCG(utils.CliTestCase):
|
|||
# is matched return the value we expected.
|
||||
self.custom_os_path_exists['/real/path/filename'] = False
|
||||
|
||||
with mock.patch(utils.get_builtin_open()), \
|
||||
mock.patch('os.path.exists', new=self.mock_os_path_exists), \
|
||||
mock.patch('koji_cli.commands.json') as json_mock:
|
||||
with mock.patch(utils.get_builtin_open()):
|
||||
with mock.patch('os.path.exists', new=self.mock_os_path_exists):
|
||||
with mock.patch('koji_cli.commands.json') as json_mock:
|
||||
|
||||
# Case 3. metafile doesn't have output section
|
||||
json_mock.load.return_value = {}
|
||||
expected = "Metadata contains no output\n"
|
||||
self.assert_system_exit(
|
||||
handle_import_cg,
|
||||
options,
|
||||
session,
|
||||
arguments,
|
||||
stdout=expected,
|
||||
exit_code=1)
|
||||
# Case 3. metafile doesn't have output section
|
||||
json_mock.load.return_value = {}
|
||||
expected = "Metadata contains no output\n"
|
||||
self.assert_system_exit(
|
||||
handle_import_cg,
|
||||
options,
|
||||
session,
|
||||
arguments,
|
||||
stdout=expected,
|
||||
exit_code=1)
|
||||
|
||||
# Case 4. path not exist
|
||||
file_path = '%(relpath)s/%(filename)s' % metadata['output'][1]
|
||||
json_mock.load.return_value = metadata
|
||||
expected = self.format_error_message(
|
||||
"No such file: %s" % file_path)
|
||||
self.assert_system_exit(
|
||||
handle_import_cg,
|
||||
options,
|
||||
session,
|
||||
arguments,
|
||||
stderr=expected)
|
||||
# Case 4. path not exist
|
||||
file_path = '%(relpath)s/%(filename)s' % metadata['output'][1]
|
||||
json_mock.load.return_value = metadata
|
||||
expected = self.format_error_message(
|
||||
"No such file: %s" % file_path)
|
||||
self.assert_system_exit(
|
||||
handle_import_cg,
|
||||
options,
|
||||
session,
|
||||
arguments,
|
||||
stderr=expected)
|
||||
|
||||
def test_handle_import_cg_help(self):
|
||||
"""Test handle_import_cg help message"""
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import libcomps
|
||||
|
|
@ -213,7 +216,10 @@ class TestImportComps(unittest.TestCase):
|
|||
session.getTag.assert_not_called()
|
||||
session.getTagGroups.assert_not_called()
|
||||
session.groupListAdd.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@unittest.skipIf(libcomps is None, "No libcomps")
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import random
|
||||
import hashlib
|
||||
import copy
|
||||
import base64
|
||||
import copy
|
||||
import hashlib
|
||||
import mock
|
||||
import random
|
||||
import six
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import call
|
||||
from koji_cli.commands import handle_import_sig
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import anon_handle_list_api
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
from six.moves import StringIO
|
||||
|
||||
import koji
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ from __future__ import absolute_import
|
|||
import mock
|
||||
import os
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from . import loadcli
|
||||
cli = loadcli.cli
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import time
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import anon_handle_list_groups
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
from six.moves import StringIO
|
||||
|
||||
import koji
|
||||
|
|
@ -37,8 +40,8 @@ class TestListNotifications(unittest.TestCase):
|
|||
self.maxDiff=None
|
||||
self.assertMultiLineEqual(actual, expected)
|
||||
activate_session_mock.assert_called_once_with(self.session, self.options)
|
||||
self.session.getTag.assert_has_calls((mock.call(1), mock.call(1)))
|
||||
self.session.getPackage.assert_has_calls((mock.call(11), mock.call(11)))
|
||||
self.session.getTag.assert_has_calls([mock.call(1), mock.call(1)])
|
||||
self.session.getPackage.assert_has_calls([mock.call(11), mock.call(11)])
|
||||
self.session.getUser.assert_not_called()
|
||||
self.session.getBuildNotifications.assert_called_once_with(None)
|
||||
|
||||
|
|
@ -67,8 +70,8 @@ class TestListNotifications(unittest.TestCase):
|
|||
self.maxDiff=None
|
||||
self.assertMultiLineEqual(actual, expected)
|
||||
activate_session_mock.assert_called_once_with(self.session, self.options)
|
||||
self.session.getTag.assert_has_calls((mock.call(1), mock.call(1)))
|
||||
self.session.getPackage.assert_has_calls((mock.call(11), mock.call(11)))
|
||||
self.session.getTag.assert_has_calls([mock.call(1), mock.call(1)])
|
||||
self.session.getPackage.assert_has_calls([mock.call(11), mock.call(11)])
|
||||
self.session.getUser.assert_called_once_with('random_name')
|
||||
self.session.getBuildNotifications.assert_called_once_with(321)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_list_permissions
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
from koji_cli.lib import _list_tasks
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_list_volumes
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import os
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from . import loadcli
|
||||
cli = loadcli.cli
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import optparse
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_maven_build
|
||||
|
||||
|
|
@ -122,7 +125,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
self.session.mavenBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
|
|
@ -162,7 +168,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
self.session.mavenBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
|
|
@ -230,7 +239,10 @@ Options:
|
|||
self.session.mavenBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 0)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -271,7 +283,10 @@ Options:
|
|||
self.session.mavenBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -316,7 +331,10 @@ Options:
|
|||
self.session.mavenBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -361,7 +379,10 @@ Options:
|
|||
self.session.mavenBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
|
|
@ -467,7 +488,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
build_opts.inis, scratch=scratch, section=section)
|
||||
maven_opts_mock.assert_not_called()
|
||||
self.session.mavenBuild.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
stdout.seek(0)
|
||||
stdout.truncate()
|
||||
|
|
@ -495,7 +519,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
build_opts.inis, scratch=scratch, section=section)
|
||||
maven_opts_mock.assert_not_called()
|
||||
self.session.mavenBuild.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
@ -547,7 +574,10 @@ Task info: weburl/taskinfo?taskID=1
|
|||
self.session.mavenBuild.assert_not_called()
|
||||
self.session.logout.assert_not_called()
|
||||
watch_tasks_mock.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_maven_chain
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import anon_handle_mock_config
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_move_build
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
import copy
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import copy
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_regen_repo
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_remove_channel
|
||||
|
||||
|
|
@ -120,7 +123,10 @@ class TestRemoveChannel(unittest.TestCase):
|
|||
activate_session_mock.assert_not_called()
|
||||
session.getChannel.assert_not_called()
|
||||
session.removeChannel.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_remove_host_from_channel
|
||||
|
||||
|
|
@ -134,7 +137,10 @@ class TestRemoveHostFromChannel(unittest.TestCase):
|
|||
session.getHost.assert_not_called()
|
||||
session.listChannels.assert_not_called()
|
||||
session.removeHostFromChannel.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import koji
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from six.moves import StringIO
|
||||
|
||||
from koji_cli.commands import handle_remove_notification
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import call
|
||||
|
||||
|
||||
|
|
@ -218,7 +222,10 @@ class TestRemovePkg(unittest.TestCase):
|
|||
session.getTag.assert_not_called()
|
||||
session.listPackages.assert_not_called()
|
||||
session.packageListRemove.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_rename_channel
|
||||
|
||||
|
|
@ -96,7 +99,11 @@ class TestRenameChannel(unittest.TestCase):
|
|||
activate_session_mock.assert_not_called()
|
||||
session.getChannel.assert_not_called()
|
||||
session.renameChannel.assert_not_called()
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
if isinstance(cm.exception, int):
|
||||
# python 2.6.6
|
||||
self.assertEqual(cm.exception, 2)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import koji
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
from koji_cli.commands import handle_restart_hosts
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ from __future__ import absolute_import
|
|||
from __future__ import print_function
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_resubmit
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_revoke_cg_access
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_revoke_permission
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.lib import _running_in_bg
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import anon_handle_search
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_set_build_volume
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_set_pkg_arches
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_set_pkg_owner
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_set_task_priority
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_tag_build
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
from __future__ import absolute_import, print_function
|
||||
import collections
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import koji
|
||||
import collections
|
||||
import time
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
from koji_cli.commands import anon_handle_taskinfo, \
|
||||
_printTaskInfo, _parseTaskParams
|
||||
|
||||
|
|
@ -423,9 +426,9 @@ Finished: Thu Jan 1 00:50:00 1970
|
|||
|
||||
""" % tuple('/mnt/koji/work/tasks/2/2/' + k for k in task_output.keys())
|
||||
|
||||
with mock.patch('sys.stdout', new_callable=six.StringIO) as stdout, \
|
||||
mock.patch('time.localtime', new=time.gmtime):
|
||||
_printTaskInfo(session, 1, '/mnt/koji')
|
||||
with mock.patch('sys.stdout', new_callable=six.StringIO) as stdout:
|
||||
with mock.patch('time.localtime', new=time.gmtime):
|
||||
_printTaskInfo(session, 1, '/mnt/koji')
|
||||
self.assert_console_message(stdout, expected)
|
||||
|
||||
@mock.patch('koji_cli.commands.list_task_output_all_volumes')
|
||||
|
|
@ -563,9 +566,9 @@ Build: bash-4.4.12-5.fc26 (1)
|
|||
Host: kojibuilder
|
||||
|
||||
"""
|
||||
with mock.patch('sys.stdout', new_callable=six.StringIO) as stdout, \
|
||||
mock.patch('time.localtime', new=time.gmtime):
|
||||
_printTaskInfo(session, 1, '/mnt/koji')
|
||||
with mock.patch('sys.stdout', new_callable=six.StringIO) as stdout:
|
||||
with mock.patch('time.localtime', new=time.gmtime):
|
||||
_printTaskInfo(session, 1, '/mnt/koji')
|
||||
self.assert_console_message(stdout, expected)
|
||||
|
||||
def test_printTaskInfo_no_task(self):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_unblock_group_pkg
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_unblock_group_req
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
|
||||
from koji_cli.commands import handle_unblock_pkg
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from six.moves import range
|
||||
|
||||
from koji_cli.lib import _unique_path
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
|
||||
from koji_cli.lib import _format_size, _format_secs, _progress_callback
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
import copy
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import copy
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import anon_handle_wait_repo
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import mock
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import call
|
||||
from six.moves import range
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from koji_cli.commands import handle_wrapper_rpm
|
||||
from . import utils
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
from __future__ import absolute_import
|
||||
import hashlib
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
import koji
|
||||
import hashlib
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import call
|
||||
import koji
|
||||
from koji_cli.commands import handle_write_signed_rpm
|
||||
from . import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
import six
|
||||
import mock
|
||||
import unittest
|
||||
import os
|
||||
import six
|
||||
import sys
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
|
@ -174,16 +178,20 @@ class CliTestCase(unittest.TestCase):
|
|||
stdout_patch = mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
stderr_patch = mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
|
||||
with session_patch as session, \
|
||||
stdout_patch as stdout, \
|
||||
stderr_patch as stderr, \
|
||||
self.assertRaises(SystemExit) as cm:
|
||||
callableObj(*test_args, **test_kwargs)
|
||||
with session_patch as session:
|
||||
with stdout_patch as stdout:
|
||||
with stderr_patch as stderr:
|
||||
with self.assertRaises(SystemExit) as cm:
|
||||
callableObj(*test_args, **test_kwargs)
|
||||
session.assert_called_once()
|
||||
self.assert_console_message(stdout, **message['stdout'])
|
||||
self.assert_console_message(stderr, **message['stderr'])
|
||||
assert_function()
|
||||
self.assertEqual(cm.exception.code, exit_code)
|
||||
if isinstance(cm.exception, int):
|
||||
# python 2.6.6
|
||||
self.assertEqual(cm.exception, exit_code)
|
||||
else:
|
||||
self.assertEqual(cm.exception.code, exit_code)
|
||||
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
def assert_help(self, callableObj, message, activate_session_mock):
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
import os
|
||||
import subprocess
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
# docs version lives in docs/source/conf.py
|
||||
TOPDIR = os.path.dirname(__file__) + '/..'
|
||||
SPHINX_CONF = TOPDIR + '/docs/source/conf.py'
|
||||
|
||||
import imp
|
||||
import os
|
||||
sphinx_conf = imp.load_source('sphinx_conf', SPHINX_CONF)
|
||||
|
||||
|
||||
|
|
@ -18,7 +22,8 @@ class TestDocsVersion(unittest.TestCase):
|
|||
def get_koji_version(self):
|
||||
spec = self.get_spec()
|
||||
cmd = ['rpm', '-q', '--specfile', spec, '--qf', '%{version}\\n']
|
||||
output = subprocess.check_output(cmd)
|
||||
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
output = popen.stdout.read()
|
||||
# rpm outputs a line for each subpackage
|
||||
version = output.splitlines()[0]
|
||||
return version
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import mock
|
||||
|
||||
import koji
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import unittest
|
||||
import mock
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import unittest
|
||||
import mock
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import copy
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
from nose.tools import eq_
|
||||
|
||||
import kojihub
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import unittest
|
||||
import mock
|
||||
import os
|
||||
import shutil
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import mock
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import koji
|
||||
import koji.policy
|
||||
import kojihub
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ import os
|
|||
import os.path
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import koji
|
||||
import koji.util
|
||||
import kojihub
|
||||
|
|
@ -160,9 +162,9 @@ class TestCompleteImageBuild(unittest.TestCase):
|
|||
return old_ip(table, *a, **kw)
|
||||
def my_ga(archive_id, **kw):
|
||||
return share['archiveinfo']
|
||||
with mock.patch('kojihub.InsertProcessor', new=my_ip), \
|
||||
mock.patch('kojihub.get_archive', new=my_ga):
|
||||
return orig_import_archive_internal(*a, **kw)
|
||||
with mock.patch('kojihub.InsertProcessor', new=my_ip):
|
||||
with mock.patch('kojihub.get_archive', new=my_ga):
|
||||
return orig_import_archive_internal(*a, **kw)
|
||||
|
||||
def set_up_callbacks(self):
|
||||
new_callbacks = copy.deepcopy(koji.plugin.callbacks)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ import os
|
|||
import os.path
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import koji
|
||||
import koji.util
|
||||
import kojihub
|
||||
|
|
@ -94,9 +96,9 @@ class TestCompleteMavenBuild(unittest.TestCase):
|
|||
return mock.MagicMock()
|
||||
def my_ga(archive_id, **kw):
|
||||
return share['archiveinfo']
|
||||
with mock.patch('kojihub.InsertProcessor', new=my_ip), \
|
||||
mock.patch('kojihub.get_archive', new=my_ga):
|
||||
orig_import_archive_internal(*a, **kw)
|
||||
with mock.patch('kojihub.InsertProcessor', new=my_ip):
|
||||
with mock.patch('kojihub.get_archive', new=my_ga):
|
||||
orig_import_archive_internal(*a, **kw)
|
||||
|
||||
def set_up_callbacks(self):
|
||||
new_callbacks = copy.deepcopy(koji.plugin.callbacks)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import copy
|
|||
import mock
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import koji
|
||||
import kojihub
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import mock
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import kojihub
|
||||
import time
|
||||
from koji import GenericError
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import mock
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import koji
|
||||
import kojihub
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
import unittest
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
import json
|
||||
import mock
|
||||
import os
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import unittest
|
||||
import mock
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue