[murano-test-runner] Mark 'package' as required parameter

Also now package param is positional.

Change-Id: I8f42821ea07b3adb4157d6a55c489a5bc2471219
Closes-Bug: #1524311
This commit is contained in:
Ekaterina Chernova 2015-12-09 15:05:09 +03:00
parent 176a58be7f
commit c4461be16a
2 changed files with 16 additions and 19 deletions
murano

@ -198,10 +198,6 @@ class MuranoTestRunner(object):
load_packages_from = self.args.load_packages_from
tests_to_run = self.args.tests
if not provided_pkg_name:
msg = _('Package name is required parameter.')
self.error(msg)
ks_opts = self._validate_keystone_opts(self.args)
client = ks_client.Client(**ks_opts)
@ -276,10 +272,6 @@ class MuranoTestRunner(object):
parser.add_argument('--os-project-name',
default=utils.env('OS_PROJECT_NAME'),
help='Defaults to env[OS_PROJECT_NAME]')
parser.add_argument('-p', '--package',
help='Full name of application package that is '
'going to be tested')
parser.add_argument('-l', '--load_packages_from',
nargs='*', metavar='</path1, /path2>',
help='Directory to search packages from. '
@ -289,6 +281,10 @@ class MuranoTestRunner(object):
help="increase output verbosity")
parser.add_argument('--version', action='version',
version=version.version_string)
parser.add_argument('package',
metavar='<PACKAGE_FQN>',
help='Full name of application package that is '
'going to be tested')
parser.add_argument('tests', nargs='*',
metavar='<testMethod1, className.testMethod2>',
help='List of method names to be tested')

@ -86,9 +86,10 @@ class TestCaseShell(testtools.TestCase):
[--os-auth-url OS_AUTH_URL]
[--os-username OS_USERNAME]
[--os-password OS_PASSWORD]
[--os-project-name OS_PROJECT_NAME] [-p PACKAGE]
[--os-project-name OS_PROJECT_NAME]
[-l [</path1, /path2> [</path1, /path2> ...]]] [-v]
[--version]
<PACKAGE_FQN>
[<testMethod1, className.testMethod2> [<testMethod1, className.testMethod2""" # noqa
self.assertIn(usage, stdout)
@ -98,7 +99,7 @@ class TestCaseShell(testtools.TestCase):
@mock.patch.object(test_runner, 'LOG')
def test_increase_verbosity(self, mock_log):
self.shell('-v -p io.murano.test.MyTest1')
self.shell('io.murano.test.MyTest1 -v')
mock_log.logger.setLevel.assert_called_with(logging.DEBUG)
@mock.patch('keystoneclient.v3.client.Client')
@ -107,12 +108,12 @@ class TestCaseShell(testtools.TestCase):
importutils.import_module('keystonemiddleware.auth_token')
self.override_config('admin_user', 'new_value', 'keystone_authtoken')
self.shell('-p io.murano.test.MyTest1 io.murano.test.MyTest2')
self.shell('io.murano.test.MyTest1 io.murano.test.MyTest2')
mock_client.assert_has_calls([mock.call(**self.auth_params)])
def test_package_all_tests(self):
_, stderr = self.shell('-v -p io.murano.test.MyTest1')
_, stderr = self.shell('io.murano.test.MyTest1 -v')
# NOTE(efedorova): May be, there is a problem with test-runner, since
# all logs are passed to stderr
self.assertIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
@ -123,7 +124,7 @@ class TestCaseShell(testtools.TestCase):
def test_package_by_class(self):
_, stderr = self.shell(
'-v -p io.murano.test.MyTest1 io.murano.test.MyTest2')
'io.murano.test.MyTest1 io.murano.test.MyTest2 -v')
self.assertNotIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
self.assertNotIn('io.murano.test.MyTest1.testSimple2.....OK', stderr)
@ -132,7 +133,7 @@ class TestCaseShell(testtools.TestCase):
def test_package_by_test_name(self):
_, stderr = self.shell(
'-v -p io.murano.test.MyTest1 testSimple1')
'io.murano.test.MyTest1 testSimple1 -v')
self.assertIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
self.assertNotIn('io.murano.test.MyTest1.testSimple2.....OK', stderr)
@ -141,7 +142,7 @@ class TestCaseShell(testtools.TestCase):
def test_package_by_test_and_class_name(self):
_, stderr = self.shell(
'-v -p io.murano.test.MyTest1 io.murano.test.MyTest2.testSimple1')
'io.murano.test.MyTest1 io.murano.test.MyTest2.testSimple1 -v')
self.assertNotIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
self.assertNotIn('io.murano.test.MyTest1.testSimple2.....OK', stderr)
@ -150,17 +151,17 @@ class TestCaseShell(testtools.TestCase):
def test_service_methods(self):
_, stderr = self.shell(
'-v -p io.murano.test.MyTest1 io.murano.test.MyTest1.testSimple1')
'io.murano.test.MyTest1 io.murano.test.MyTest1.testSimple1 -v')
self.assertIn('Executing: io.murano.test.MyTest1.setUp', stderr)
self.assertIn('Executing: io.murano.test.MyTest1.tearDown', stderr)
def test_package_is_not_provided(self):
_, stderr = self.shell(exitcode=1)
self.assertIn('ERROR: Package name is required parameter.', stderr)
_, stderr = self.shell(exitcode=2)
self.assertIn('murano-test-runner: error: too few arguments', stderr)
def test_wrong_parent(self):
_, stderr = self.shell(
'-v -p io.murano.test.MyTest1 io.murano.test.MyTest3', exitcode=1)
'io.murano.test.MyTest1 io.murano.test.MyTest3 -v', exitcode=1)
self.assertIn('Class io.murano.test.MyTest3 is not inherited from'
' io.murano.test.TestFixture. Skipping it.', stderr)
self.assertIn('No tests found for execution.', stderr)