From 04387deeab820e75c6d37d2ddd5b514cb7bcfd9e Mon Sep 17 00:00:00 2001 From: Pavel Aharoni Date: Sun, 11 Jun 2017 14:33:57 +0300 Subject: [SDC-32] separate Tosca Parser from DC Change-Id: I7e7f31ff2bd92fec22031f75b7051d129a21d01b Signed-off-by: Pavel Aharoni --- .../cliff-2.4.0-py2.7.egg/cliff/tests/__init__.py | 0 .../cliff-2.4.0-py2.7.egg/cliff/tests/test_app.py | 498 ------------------- .../cliff/tests/test_columns.py | 30 -- .../cliff/tests/test_command.py | 64 --- .../cliff/tests/test_commandmanager.py | 132 ----- .../cliff/tests/test_complete.py | 173 ------- .../cliff/tests/test_formatters_csv.py | 85 ---- .../cliff/tests/test_formatters_json.py | 129 ----- .../cliff/tests/test_formatters_shell.py | 96 ---- .../cliff/tests/test_formatters_table.py | 547 --------------------- .../cliff/tests/test_formatters_value.py | 65 --- .../cliff/tests/test_formatters_yaml.py | 100 ---- .../cliff-2.4.0-py2.7.egg/cliff/tests/test_help.py | 180 ------- .../cliff/tests/test_interactive.py | 74 --- .../cliff/tests/test_lister.py | 75 --- .../cliff-2.4.0-py2.7.egg/cliff/tests/test_show.py | 84 ---- .../cliff/tests/test_utils.py | 79 --- .../cliff-2.4.0-py2.7.egg/cliff/tests/utils.py | 48 -- 18 files changed, 2459 deletions(-) delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/__init__.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_app.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_columns.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_command.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_commandmanager.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_complete.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_csv.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_json.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_shell.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_table.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_value.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_yaml.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_help.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_interactive.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_lister.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_show.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_utils.py delete mode 100644 jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/utils.py (limited to 'jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests') diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/__init__.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_app.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_app.py deleted file mode 100644 index 26149a2..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_app.py +++ /dev/null @@ -1,498 +0,0 @@ -# -*- encoding: utf-8 -*- -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import argparse -try: - from StringIO import StringIO -except ImportError: - from io import StringIO - -import codecs -import locale -import mock -import six -import sys - -from cliff import app as application -from cliff import command as c_cmd -from cliff import commandmanager -from cliff.tests import utils as test_utils -from cliff import utils - - -def make_app(**kwargs): - cmd_mgr = commandmanager.CommandManager('cliff.tests') - - # Register a command that succeeds - command = mock.MagicMock(spec=c_cmd.Command) - command_inst = mock.MagicMock(spec=c_cmd.Command) - command_inst.run.return_value = 0 - command.return_value = command_inst - cmd_mgr.add_command('mock', command) - - # Register a command that fails - err_command = mock.Mock(name='err_command', spec=c_cmd.Command) - err_command_inst = mock.Mock(spec=c_cmd.Command) - err_command_inst.run = mock.Mock( - side_effect=RuntimeError('test exception') - ) - err_command.return_value = err_command_inst - cmd_mgr.add_command('error', err_command) - - app = application.App('testing interactive mode', - '1', - cmd_mgr, - stderr=mock.Mock(), # suppress warning messages - **kwargs - ) - return app, command - - -def test_no_args_triggers_interactive_mode(): - app, command = make_app() - app.interact = mock.MagicMock(name='inspect') - app.run([]) - app.interact.assert_called_once_with() - - -def test_interactive_mode_cmdloop(): - app, command = make_app() - app.interactive_app_factory = mock.MagicMock( - name='interactive_app_factory' - ) - assert app.interpreter is None - app.run([]) - assert app.interpreter is not None - app.interactive_app_factory.return_value.cmdloop.assert_called_once_with() - - -def test_initialize_app(): - app, command = make_app() - app.initialize_app = mock.MagicMock(name='initialize_app') - app.run(['mock']) - app.initialize_app.assert_called_once_with(['mock']) - - -def test_prepare_to_run_command(): - app, command = make_app() - app.prepare_to_run_command = mock.MagicMock(name='prepare_to_run_command') - app.run(['mock']) - app.prepare_to_run_command.assert_called_once_with(command()) - - -def test_clean_up_success(): - app, command = make_app() - app.clean_up = mock.MagicMock(name='clean_up') - app.run(['mock']) - app.clean_up.assert_called_once_with(command.return_value, 0, None) - - -def test_clean_up_error(): - app, command = make_app() - - app.clean_up = mock.MagicMock(name='clean_up') - app.run(['error']) - - app.clean_up.assert_called_once_with(mock.ANY, mock.ANY, mock.ANY) - call_args = app.clean_up.call_args_list[0] - assert call_args == mock.call(mock.ANY, 1, mock.ANY) - args, kwargs = call_args - assert isinstance(args[2], RuntimeError) - assert args[2].args == ('test exception',) - - -def test_clean_up_error_debug(): - app, command = make_app() - - app.clean_up = mock.MagicMock(name='clean_up') - try: - app.run(['--debug', 'error']) - except RuntimeError as err: - assert app.clean_up.call_args_list[0][0][2] is err - else: - assert False, 'Should have had an exception' - - assert app.clean_up.called - call_args = app.clean_up.call_args_list[0] - assert call_args == mock.call(mock.ANY, 1, mock.ANY) - args, kwargs = call_args - assert isinstance(args[2], RuntimeError) - assert args[2].args == ('test exception',) - - -def test_error_handling_clean_up_raises_exception(): - app, command = make_app() - - app.clean_up = mock.MagicMock( - name='clean_up', - side_effect=RuntimeError('within clean_up'), - ) - app.run(['error']) - - assert app.clean_up.called - call_args = app.clean_up.call_args_list[0] - assert call_args == mock.call(mock.ANY, 1, mock.ANY) - args, kwargs = call_args - assert isinstance(args[2], RuntimeError) - assert args[2].args == ('test exception',) - - -def test_error_handling_clean_up_raises_exception_debug(): - app, command = make_app() - - app.clean_up = mock.MagicMock( - name='clean_up', - side_effect=RuntimeError('within clean_up'), - ) - try: - app.run(['--debug', 'error']) - except RuntimeError as err: - if not hasattr(err, '__context__'): - # The exception passed to clean_up is not the exception - # caused *by* clean_up. This test is only valid in python - # 2 because under v3 the original exception is re-raised - # with the new one as a __context__ attribute. - assert app.clean_up.call_args_list[0][0][2] is not err - else: - assert False, 'Should have had an exception' - - assert app.clean_up.called - call_args = app.clean_up.call_args_list[0] - assert call_args == mock.call(mock.ANY, 1, mock.ANY) - args, kwargs = call_args - assert isinstance(args[2], RuntimeError) - assert args[2].args == ('test exception',) - - -def test_normal_clean_up_raises_exception(): - app, command = make_app() - - app.clean_up = mock.MagicMock( - name='clean_up', - side_effect=RuntimeError('within clean_up'), - ) - app.run(['mock']) - - assert app.clean_up.called - call_args = app.clean_up.call_args_list[0] - assert call_args == mock.call(mock.ANY, 0, None) - - -def test_normal_clean_up_raises_exception_debug(): - app, command = make_app() - - app.clean_up = mock.MagicMock( - name='clean_up', - side_effect=RuntimeError('within clean_up'), - ) - app.run(['--debug', 'mock']) - - assert app.clean_up.called - call_args = app.clean_up.call_args_list[0] - assert call_args == mock.call(mock.ANY, 0, None) - - -def test_build_option_parser_conflicting_option_should_throw(): - class MyApp(application.App): - def __init__(self): - super(MyApp, self).__init__( - description='testing', - version='0.1', - command_manager=commandmanager.CommandManager('tests'), - ) - - def build_option_parser(self, description, version): - parser = super(MyApp, self).build_option_parser(description, - version) - parser.add_argument( - '-h', '--help', - default=self, # tricky - help="Show help message and exit.", - ) - - # TODO: tests should really use unittest2. - try: - MyApp() - except argparse.ArgumentError: - pass - else: - raise Exception('Exception was not thrown') - - -def test_option_parser_conflicting_option_custom_arguments_should_not_throw(): - class MyApp(application.App): - def __init__(self): - super(MyApp, self).__init__( - description='testing', - version='0.1', - command_manager=commandmanager.CommandManager('tests'), - ) - - def build_option_parser(self, description, version): - argparse_kwargs = {'conflict_handler': 'resolve'} - parser = super(MyApp, self).build_option_parser( - description, - version, - argparse_kwargs=argparse_kwargs) - parser.add_argument( - '-h', '--help', - default=self, # tricky - help="Show help message and exit.", - ) - - MyApp() - - -def test_option_parser_abbrev_issue(): - class MyCommand(c_cmd.Command): - def get_parser(self, prog_name): - parser = super(MyCommand, self).get_parser(prog_name) - parser.add_argument("--end") - return parser - - def take_action(self, parsed_args): - assert(parsed_args.end == '123') - - class MyCommandManager(commandmanager.CommandManager): - def load_commands(self, namespace): - self.add_command("mycommand", MyCommand) - - class MyApp(application.App): - def __init__(self): - super(MyApp, self).__init__( - description='testing', - version='0.1', - command_manager=MyCommandManager(None), - ) - - def build_option_parser(self, description, version): - parser = super(MyApp, self).build_option_parser( - description, - version, - argparse_kwargs={'allow_abbrev': False}) - parser.add_argument('--endpoint') - return parser - - app = MyApp() - # NOTE(jd) --debug is necessary so assert in take_action() raises correctly - # here - app.run(['--debug', 'mycommand', '--end', '123']) - - -def _test_help(deferred_help): - app, _ = make_app(deferred_help=deferred_help) - with mock.patch.object(app, 'initialize_app') as init: - with mock.patch('cliff.help.HelpAction.__call__', - side_effect=SystemExit(0)) as helper: - try: - app.run(['--help']) - except SystemExit: - pass - else: - raise Exception('Exception was not thrown') - assert helper.called - assert init.called == deferred_help - - -def test_help(): - _test_help(False) - - -def test_deferred_help(): - _test_help(True) - - -def test_subcommand_help(): - app, _ = make_app(deferred_help=False) - - # Help is called immediately - with mock.patch('cliff.help.HelpAction.__call__') as helper: - app.run(['show', 'files', '--help']) - - assert helper.called - - -def test_subcommand_deferred_help(): - app, _ = make_app(deferred_help=True) - - # Show that provide_help_if_requested() did not show help and exit - with mock.patch.object(app, 'run_subcommand') as helper: - app.run(['show', 'files', '--help']) - - helper.assert_called_once_with(['help', 'show', 'files']) - - -def test_unknown_cmd(): - app, command = make_app() - assert app.run(['hell']) == 2 - - -def test_unknown_cmd_debug(): - app, command = make_app() - try: - app.run(['--debug', 'hell']) == 2 - except ValueError as err: - assert "['hell']" in ('%s' % err) - - -def test_list_matching_commands(): - stdout = StringIO() - app = application.App('testing', '1', - test_utils.TestCommandManager( - test_utils.TEST_NAMESPACE), - stdout=stdout) - app.NAME = 'test' - try: - assert app.run(['t']) == 2 - except SystemExit: - pass - output = stdout.getvalue() - assert "test: 't' is not a test command. See 'test --help'." in output - assert 'Did you mean one of these?' in output - assert 'three word command\n two words\n' in output - - -def test_fuzzy_no_commands(): - cmd_mgr = commandmanager.CommandManager('cliff.fuzzy') - app = application.App('test', '1.0', cmd_mgr) - cmd_mgr.commands = {} - matches = app.get_fuzzy_matches('foo') - assert matches == [] - - -def test_fuzzy_common_prefix(): - # searched string is a prefix of all commands - cmd_mgr = commandmanager.CommandManager('cliff.fuzzy') - app = application.App('test', '1.0', cmd_mgr) - cmd_mgr.commands = {} - cmd_mgr.add_command('user list', test_utils.TestCommand) - cmd_mgr.add_command('user show', test_utils.TestCommand) - matches = app.get_fuzzy_matches('user') - assert matches == ['user list', 'user show'] - - -def test_fuzzy_same_distance(): - # searched string has the same distance to all commands - cmd_mgr = commandmanager.CommandManager('cliff.fuzzy') - app = application.App('test', '1.0', cmd_mgr) - cmd_mgr.add_command('user', test_utils.TestCommand) - for cmd in cmd_mgr.commands.keys(): - assert utils.damerau_levenshtein('node', cmd, utils.COST) == 8 - matches = app.get_fuzzy_matches('node') - assert matches == ['complete', 'help', 'user'] - - -def test_fuzzy_no_prefix(): - # search by distance, no common prefix with any command - cmd_mgr = commandmanager.CommandManager('cliff.fuzzy') - app = application.App('test', '1.0', cmd_mgr) - cmd_mgr.add_command('user', test_utils.TestCommand) - matches = app.get_fuzzy_matches('uesr') - assert matches == ['user'] - - -def test_verbose(): - app, command = make_app() - app.clean_up = mock.MagicMock(name='clean_up') - app.run(['--verbose', 'mock']) - app.clean_up.assert_called_once_with(command.return_value, 0, None) - app.clean_up.reset_mock() - app.run(['--quiet', 'mock']) - app.clean_up.assert_called_once_with(command.return_value, 0, None) - try: - app.run(['--verbose', '--quiet', 'mock']) - except SystemExit: - pass - else: - raise Exception('Exception was not thrown') - - -def test_io_streams(): - cmd_mgr = commandmanager.CommandManager('cliff.tests') - io = mock.Mock() - - if six.PY2: - stdin_save = sys.stdin - stdout_save = sys.stdout - stderr_save = sys.stderr - encoding = locale.getpreferredencoding() or 'utf-8' - - app = application.App('no io streams', 1, cmd_mgr) - assert isinstance(app.stdin, codecs.StreamReader) - assert isinstance(app.stdout, codecs.StreamWriter) - assert isinstance(app.stderr, codecs.StreamWriter) - - app = application.App('with stdin io stream', 1, cmd_mgr, stdin=io) - assert app.stdin is io - assert isinstance(app.stdout, codecs.StreamWriter) - assert isinstance(app.stderr, codecs.StreamWriter) - - app = application.App('with stdout io stream', 1, cmd_mgr, stdout=io) - assert isinstance(app.stdin, codecs.StreamReader) - assert app.stdout is io - assert isinstance(app.stderr, codecs.StreamWriter) - - app = application.App('with stderr io stream', 1, cmd_mgr, stderr=io) - assert isinstance(app.stdin, codecs.StreamReader) - assert isinstance(app.stdout, codecs.StreamWriter) - assert app.stderr is io - - try: - sys.stdin = codecs.getreader(encoding)(sys.stdin) - app = application.App( - 'with wrapped sys.stdin io stream', 1, cmd_mgr) - assert app.stdin is sys.stdin - assert isinstance(app.stdout, codecs.StreamWriter) - assert isinstance(app.stderr, codecs.StreamWriter) - finally: - sys.stdin = stdin_save - - try: - sys.stdout = codecs.getwriter(encoding)(sys.stdout) - app = application.App('with wrapped stdout io stream', 1, cmd_mgr) - assert isinstance(app.stdin, codecs.StreamReader) - assert app.stdout is sys.stdout - assert isinstance(app.stderr, codecs.StreamWriter) - finally: - sys.stdout = stdout_save - - try: - sys.stderr = codecs.getwriter(encoding)(sys.stderr) - app = application.App('with wrapped stderr io stream', 1, cmd_mgr) - assert isinstance(app.stdin, codecs.StreamReader) - assert isinstance(app.stdout, codecs.StreamWriter) - assert app.stderr is sys.stderr - finally: - sys.stderr = stderr_save - - else: - app = application.App('no io streams', 1, cmd_mgr) - assert app.stdin is sys.stdin - assert app.stdout is sys.stdout - assert app.stderr is sys.stderr - - app = application.App('with stdin io stream', 1, cmd_mgr, stdin=io) - assert app.stdin is io - assert app.stdout is sys.stdout - assert app.stderr is sys.stderr - - app = application.App('with stdout io stream', 1, cmd_mgr, stdout=io) - assert app.stdin is sys.stdin - assert app.stdout is io - assert app.stderr is sys.stderr - - app = application.App('with stderr io stream', 1, cmd_mgr, stderr=io) - assert app.stdin is sys.stdin - assert app.stdout is sys.stdout - assert app.stderr is io diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_columns.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_columns.py deleted file mode 100644 index d7bb2b0..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_columns.py +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from cliff import columns - - -class FauxColumn(columns.FormattableColumn): - - def human_readable(self): - return u'I made this string myself: {}'.format(self._value) - - -def test_faux_column_machine(): - c = FauxColumn(['list', 'of', 'values']) - assert c.machine_readable() == ['list', 'of', 'values'] - - -def test_faux_column_human(): - c = FauxColumn(['list', 'of', 'values']) - assert c.human_readable() == \ - u"I made this string myself: ['list', 'of', 'values']" diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_command.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_command.py deleted file mode 100644 index ef6b051..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_command.py +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from cliff import command - - -class TestCommand(command.Command): - """Description of command. - """ - - def take_action(self, parsed_args): - return 42 - - -class TestCommandNoDocstring(command.Command): - - def take_action(self, parsed_args): - return 42 - - -def test_get_description_docstring(): - cmd = TestCommand(None, None) - desc = cmd.get_description() - assert desc == "Description of command.\n " - - -def test_get_description_attribute(): - cmd = TestCommand(None, None) - # Artificially inject a value for _description to verify that it - # overrides the docstring. - cmd._description = 'this is not the default' - desc = cmd.get_description() - assert desc == 'this is not the default' - - -def test_get_description_default(): - cmd = TestCommandNoDocstring(None, None) - desc = cmd.get_description() - assert desc == '' - - -def test_get_parser(): - cmd = TestCommand(None, None) - parser = cmd.get_parser('NAME') - assert parser.prog == 'NAME' - - -def test_get_name(): - cmd = TestCommand(None, None, cmd_name='object action') - assert cmd.cmd_name == 'object action' - - -def test_run_return(): - cmd = TestCommand(None, None, cmd_name='object action') - assert cmd.run(None) == 42 diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_commandmanager.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_commandmanager.py deleted file mode 100644 index 7f5ce0c..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_commandmanager.py +++ /dev/null @@ -1,132 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock - -from cliff import commandmanager -from cliff.tests import utils - - -def test_lookup_and_find(): - def check(mgr, argv): - cmd, name, remaining = mgr.find_command(argv) - assert cmd - assert name == ' '.join(argv) - assert not remaining - mgr = utils.TestCommandManager(utils.TEST_NAMESPACE) - for expected in [['one'], - ['two', 'words'], - ['three', 'word', 'command'], - ]: - yield check, mgr, expected - return - - -def test_lookup_with_remainder(): - def check(mgr, argv): - cmd, name, remaining = mgr.find_command(argv) - assert cmd - assert remaining == ['--opt'] - mgr = utils.TestCommandManager(utils.TEST_NAMESPACE) - for expected in [['one', '--opt'], - ['two', 'words', '--opt'], - ['three', 'word', 'command', '--opt'], - ]: - yield check, mgr, expected - return - - -def test_find_invalid_command(): - mgr = utils.TestCommandManager(utils.TEST_NAMESPACE) - - def check_one(argv): - try: - mgr.find_command(argv) - except ValueError as err: - # make sure err include 'a' when ['a', '-b'] - assert argv[0] in ('%s' % err) - assert '-b' in ('%s' % err) - else: - assert False, 'expected a failure' - for argv in [['a', '-b'], - ['-b'], - ]: - yield check_one, argv - - -def test_find_unknown_command(): - mgr = utils.TestCommandManager(utils.TEST_NAMESPACE) - try: - mgr.find_command(['a', 'b']) - except ValueError as err: - assert "['a', 'b']" in ('%s' % err) - else: - assert False, 'expected a failure' - - -def test_add_command(): - mgr = utils.TestCommandManager(utils.TEST_NAMESPACE) - mock_cmd = mock.Mock() - mgr.add_command('mock', mock_cmd) - found_cmd, name, args = mgr.find_command(['mock']) - assert found_cmd is mock_cmd - - -def test_intersected_commands(): - def foo(arg): - pass - - def foo_bar(): - pass - - mgr = utils.TestCommandManager(utils.TEST_NAMESPACE) - mgr.add_command('foo', foo) - mgr.add_command('foo bar', foo_bar) - - assert mgr.find_command(['foo', 'bar'])[0] is foo_bar - assert mgr.find_command(['foo', 'arg0'])[0] is foo - - -def test_load_commands(): - testcmd = mock.Mock(name='testcmd') - testcmd.name.replace.return_value = 'test' - mock_pkg_resources = mock.Mock(return_value=[testcmd]) - with mock.patch('pkg_resources.iter_entry_points', - mock_pkg_resources) as iter_entry_points: - mgr = commandmanager.CommandManager('test') - iter_entry_points.assert_called_once_with('test') - names = [n for n, v in mgr] - assert names == ['test'] - - -def test_load_commands_keep_underscores(): - testcmd = mock.Mock() - testcmd.name = 'test_cmd' - mock_pkg_resources = mock.Mock(return_value=[testcmd]) - with mock.patch('pkg_resources.iter_entry_points', - mock_pkg_resources) as iter_entry_points: - mgr = commandmanager.CommandManager('test', convert_underscores=False) - iter_entry_points.assert_called_once_with('test') - names = [n for n, v in mgr] - assert names == ['test_cmd'] - - -def test_load_commands_replace_underscores(): - testcmd = mock.Mock() - testcmd.name = 'test_cmd' - mock_pkg_resources = mock.Mock(return_value=[testcmd]) - with mock.patch('pkg_resources.iter_entry_points', - mock_pkg_resources) as iter_entry_points: - mgr = commandmanager.CommandManager('test', convert_underscores=True) - iter_entry_points.assert_called_once_with('test') - names = [n for n, v in mgr] - assert names == ['test cmd'] diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_complete.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_complete.py deleted file mode 100644 index b1523ec..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_complete.py +++ /dev/null @@ -1,173 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -"""Bash completion tests -""" - -import mock - -from cliff import app as application -from cliff import commandmanager -from cliff import complete - - -def test_complete_dictionary(): - sot = complete.CompleteDictionary() - sot.add_command("image delete".split(), - [mock.Mock(option_strings=["1"])]) - sot.add_command("image list".split(), - [mock.Mock(option_strings=["2"])]) - sot.add_command("image create".split(), - [mock.Mock(option_strings=["3"])]) - sot.add_command("volume type create".split(), - [mock.Mock(option_strings=["4"])]) - sot.add_command("volume type delete".split(), - [mock.Mock(option_strings=["5"])]) - assert "image volume" == sot.get_commands() - result = sot.get_data() - assert "image" == result[0][0] - assert "create delete list" == result[0][1] - assert "image_create" == result[1][0] - assert "3" == result[1][1] - assert "image_delete" == result[2][0] - assert "1" == result[2][1] - assert "image_list" == result[3][0] - assert "2" == result[3][1] - - -def test_complete_dictionary_subcmd(): - sot = complete.CompleteDictionary() - sot.add_command("image delete".split(), - [mock.Mock(option_strings=["1"])]) - sot.add_command("image list".split(), - [mock.Mock(option_strings=["2"])]) - sot.add_command("image list better".split(), - [mock.Mock(option_strings=["3"])]) - assert "image" == sot.get_commands() - result = sot.get_data() - assert "image" == result[0][0] - assert "delete list list_better" == result[0][1] - assert "image_delete" == result[1][0] - assert "1" == result[1][1] - assert "image_list" == result[2][0] - assert "2 better" == result[2][1] - assert "image_list_better" == result[3][0] - assert "3" == result[3][1] - - -class FakeStdout: - def __init__(self): - self.content = [] - - def write(self, text): - self.content.append(text) - - def make_string(self): - result = '' - for line in self.content: - result = result + line - return result - - -def given_cmdo_data(): - cmdo = "image server" - data = [("image", "create"), - ("image_create", "--eolus"), - ("server", "meta ssh"), - ("server_meta_delete", "--wilson"), - ("server_ssh", "--sunlight")] - return cmdo, data - - -def then_data(content): - assert " cmds='image server'\n" in content - assert " cmds_image='create'\n" in content - assert " cmds_image_create='--eolus'\n" in content - assert " cmds_server='meta ssh'\n" in content - assert " cmds_server_meta_delete='--wilson'\n" in content - assert " cmds_server_ssh='--sunlight'\n" in content - - -def test_complete_no_code(): - output = FakeStdout() - sot = complete.CompleteNoCode("doesNotMatter", output) - sot.write(*given_cmdo_data()) - then_data(output.content) - - -def test_complete_bash(): - output = FakeStdout() - sot = complete.CompleteBash("openstack", output) - sot.write(*given_cmdo_data()) - then_data(output.content) - assert "_openstack()\n" in output.content[0] - assert "complete -F _openstack openstack\n" in output.content[-1] - - -def test_complete_command_parser(): - sot = complete.CompleteCommand(mock.Mock(), mock.Mock()) - parser = sot.get_parser('nothing') - assert "nothing" == parser.prog - assert "print bash completion command\n " == parser.description - - -def given_complete_command(): - cmd_mgr = commandmanager.CommandManager('cliff.tests') - app = application.App('testing', '1', cmd_mgr, stdout=FakeStdout()) - sot = complete.CompleteCommand(app, mock.Mock()) - cmd_mgr.add_command('complete', complete.CompleteCommand) - return sot, app, cmd_mgr - - -def then_actions_equal(actions): - optstr = ' '.join(opt for action in actions - for opt in action.option_strings) - assert '-h --help --name --shell' == optstr - - -def test_complete_command_get_actions(): - sot, app, cmd_mgr = given_complete_command() - app.interactive_mode = False - actions = sot.get_actions(["complete"]) - then_actions_equal(actions) - - -def test_complete_command_get_actions_interactive(): - sot, app, cmd_mgr = given_complete_command() - app.interactive_mode = True - actions = sot.get_actions(["complete"]) - then_actions_equal(actions) - - -def test_complete_command_take_action(): - sot, app, cmd_mgr = given_complete_command() - parsed_args = mock.Mock() - parsed_args.name = "test_take" - parsed_args.shell = "bash" - content = app.stdout.content - assert 0 == sot.take_action(parsed_args) - assert "_test_take()\n" in content[0] - assert "complete -F _test_take test_take\n" in content[-1] - assert " cmds='complete help'\n" in content - assert " cmds_complete='-h --help --name --shell'\n" in content - assert " cmds_help='-h --help'\n" in content - - -def test_complete_command_remove_dashes(): - sot, app, cmd_mgr = given_complete_command() - parsed_args = mock.Mock() - parsed_args.name = "test-take" - parsed_args.shell = "bash" - content = app.stdout.content - assert 0 == sot.take_action(parsed_args) - assert "_test_take()\n" in content[0] - assert "complete -F _test_take test-take\n" in content[-1] diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_csv.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_csv.py deleted file mode 100644 index 27c6f84..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_csv.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -import argparse -import six - -from cliff.formatters import commaseparated -from cliff.tests import test_columns - - -def test_commaseparated_list_formatter(): - sf = commaseparated.CSVLister() - c = ('a', 'b', 'c') - d1 = ('A', 'B', 'C') - d2 = ('D', 'E', 'F') - data = [d1, d2] - expected = 'a,b,c\nA,B,C\nD,E,F\n' - output = six.StringIO() - parsed_args = mock.Mock() - parsed_args.quote_mode = 'none' - sf.emit_list(c, data, output, parsed_args) - actual = output.getvalue() - assert expected == actual - - -def test_commaseparated_list_formatter_quoted(): - sf = commaseparated.CSVLister() - c = ('a', 'b', 'c') - d1 = ('A', 'B', 'C') - d2 = ('D', 'E', 'F') - data = [d1, d2] - expected = '"a","b","c"\n"A","B","C"\n"D","E","F"\n' - output = six.StringIO() - # Parse arguments as if passed on the command-line - parser = argparse.ArgumentParser(description='Testing...') - sf.add_argument_group(parser) - parsed_args = parser.parse_args(['--quote', 'all']) - sf.emit_list(c, data, output, parsed_args) - actual = output.getvalue() - assert expected == actual - - -def test_commaseparated_list_formatter_formattable_column(): - sf = commaseparated.CSVLister() - c = ('a', 'b', 'c') - d1 = ('A', 'B', test_columns.FauxColumn(['the', 'value'])) - data = [d1] - expected = 'a,b,c\nA,B,[\'the\'\\, \'value\']\n' - output = six.StringIO() - parsed_args = mock.Mock() - parsed_args.quote_mode = 'none' - sf.emit_list(c, data, output, parsed_args) - actual = output.getvalue() - assert expected == actual - - -def test_commaseparated_list_formatter_unicode(): - sf = commaseparated.CSVLister() - c = (u'a', u'b', u'c') - d1 = (u'A', u'B', u'C') - happy = u'高兴' - d2 = (u'D', u'E', happy) - data = [d1, d2] - expected = u'a,b,c\nA,B,C\nD,E,%s\n' % happy - output = six.StringIO() - parsed_args = mock.Mock() - parsed_args.quote_mode = 'none' - sf.emit_list(c, data, output, parsed_args) - actual = output.getvalue() - if six.PY2: - actual = actual.decode('utf-8') - assert expected == actual diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_json.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_json.py deleted file mode 100644 index eb7397d..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_json.py +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env python -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import json -import six - -from cliff.formatters import json_format -from cliff.tests import test_columns - -import mock - - -def test_json_format_one(): - sf = json_format.JSONFormatter() - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', '"escape me"') - expected = { - 'a': 'A', - 'b': 'B', - 'c': 'C', - 'd': '"escape me"' - } - args = mock.Mock() - sf.add_argument_group(args) - - args.noindent = True - output = six.StringIO() - sf.emit_one(c, d, output, args) - value = output.getvalue() - print(len(value.splitlines())) - assert 1 == len(value.splitlines()) - actual = json.loads(value) - assert expected == actual - - args.noindent = False - output = six.StringIO() - sf.emit_one(c, d, output, args) - value = output.getvalue() - assert 6 == len(value.splitlines()) - actual = json.loads(value) - assert expected == actual - - -def test_json_format_formattablecolumn_one(): - sf = json_format.JSONFormatter() - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', test_columns.FauxColumn(['the', 'value'])) - expected = { - 'a': 'A', - 'b': 'B', - 'c': 'C', - 'd': ['the', 'value'], - } - args = mock.Mock() - sf.add_argument_group(args) - - args.noindent = True - output = six.StringIO() - sf.emit_one(c, d, output, args) - value = output.getvalue() - print(len(value.splitlines())) - assert 1 == len(value.splitlines()) - actual = json.loads(value) - assert expected == actual - - -def test_json_format_list(): - sf = json_format.JSONFormatter() - c = ('a', 'b', 'c') - d = ( - ('A1', 'B1', 'C1'), - ('A2', 'B2', 'C2'), - ('A3', 'B3', 'C3') - ) - expected = [ - {'a': 'A1', 'b': 'B1', 'c': 'C1'}, - {'a': 'A2', 'b': 'B2', 'c': 'C2'}, - {'a': 'A3', 'b': 'B3', 'c': 'C3'} - ] - args = mock.Mock() - sf.add_argument_group(args) - - args.noindent = True - output = six.StringIO() - sf.emit_list(c, d, output, args) - value = output.getvalue() - assert 1 == len(value.splitlines()) - actual = json.loads(value) - assert expected == actual - - args.noindent = False - output = six.StringIO() - sf.emit_list(c, d, output, args) - value = output.getvalue() - assert 17 == len(value.splitlines()) - actual = json.loads(value) - assert expected == actual - - -def test_json_format_formattablecolumn_list(): - sf = json_format.JSONFormatter() - c = ('a', 'b', 'c') - d = ( - ('A1', 'B1', test_columns.FauxColumn(['the', 'value'])), - ) - expected = [ - {'a': 'A1', 'b': 'B1', 'c': ['the', 'value']}, - ] - args = mock.Mock() - sf.add_argument_group(args) - - args.noindent = True - output = six.StringIO() - sf.emit_list(c, d, output, args) - value = output.getvalue() - assert 1 == len(value.splitlines()) - actual = json.loads(value) - assert expected == actual diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_shell.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_shell.py deleted file mode 100644 index 7689f73..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_shell.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import argparse -import six - -from cliff.formatters import shell -from cliff.tests import test_columns - -import mock - - -def test_shell_formatter(): - sf = shell.ShellFormatter() - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', '"escape me"') - expected = 'a="A"\nb="B"\nd="\\"escape me\\""\n' - output = six.StringIO() - args = mock.Mock() - args.variables = ['a', 'b', 'd'] - args.prefix = '' - sf.emit_one(c, d, output, args) - actual = output.getvalue() - assert expected == actual - - -def test_shell_formatter_args(): - sf = shell.ShellFormatter() - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', '"escape me"') - expected = 'Xd="\\"escape me\\""\n' - output = six.StringIO() - # Parse arguments as if passed on the command-line - parser = argparse.ArgumentParser(description='Testing...') - sf.add_argument_group(parser) - parsed_args = parser.parse_args(['--variable', 'd', '--prefix', 'X']) - sf.emit_one(c, d, output, parsed_args) - actual = output.getvalue() - assert expected == actual - - -def test_shell_formatter_formattable_column(): - sf = shell.ShellFormatter() - c = ('a', 'b', 'c') - d = ('A', 'B', test_columns.FauxColumn(['the', 'value'])) - expected = '\n'.join([ - 'a="A"', - 'b="B"', - 'c="[\'the\', \'value\']"\n', - ]) - output = six.StringIO() - args = mock.Mock() - args.variables = ['a', 'b', 'c'] - args.prefix = '' - sf.emit_one(c, d, output, args) - actual = output.getvalue() - assert expected == actual - - -def test_shell_formatter_with_non_string_values(): - sf = shell.ShellFormatter() - c = ('a', 'b', 'c', 'd', 'e') - d = (True, False, 100, '"esc"', six.text_type('"esc"')) - expected = 'a="True"\nb="False"\nc="100"\nd="\\"esc\\""\ne="\\"esc\\""\n' - output = six.StringIO() - args = mock.Mock() - args.variables = ['a', 'b', 'c', 'd', 'e'] - args.prefix = '' - sf.emit_one(c, d, output, args) - actual = output.getvalue() - assert expected == actual - - -def test_shell_formatter_with_non_bash_friendly_values(): - sf = shell.ShellFormatter() - c = ('a', 'foo-bar', 'provider:network_type') - d = (True, 'baz', 'vxlan') - expected = 'a="True"\nfoo_bar="baz"\nprovider_network_type="vxlan"\n' - output = six.StringIO() - args = mock.Mock() - args.variables = ['a', 'foo-bar', 'provider:network_type'] - args.prefix = '' - sf.emit_one(c, d, output, args) - actual = output.getvalue() - assert expected == actual diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_table.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_table.py deleted file mode 100644 index 7e8cf97..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_table.py +++ /dev/null @@ -1,547 +0,0 @@ -#!/usr/bin/env python -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import mock -from six import StringIO -import os -import argparse - -from cliff.formatters import table -from cliff.tests import test_columns - - -class args(object): - def __init__(self, max_width=0, print_empty=False): - if max_width > 0: - self.max_width = max_width - else: - # Envvar is only taken into account iff CLI parameter not given - self.max_width = int(os.environ.get('CLIFF_MAX_TERM_WIDTH', 0)) - self.print_empty = print_empty - - -def _table_tester_helper(tags, data, extra_args=None): - """Get table output as a string, formatted according to - CLI arguments, environment variables and terminal size - - tags - tuple of strings for data tags (column headers or fields) - data - tuple of strings for single data row - - list of tuples of strings for multiple rows of data - extra_args - an instance of class args - - a list of strings for CLI arguments - """ - sf = table.TableFormatter() - - if extra_args is None: - # Default to no CLI arguments - parsed_args = args() - elif type(extra_args) == args: - # Use the given CLI arguments - parsed_args = extra_args - else: - # Parse arguments as if passed on the command-line - parser = argparse.ArgumentParser(description='Testing...') - sf.add_argument_group(parser) - parsed_args = parser.parse_args(extra_args) - - output = StringIO() - emitter = sf.emit_list if type(data) is list else sf.emit_one - emitter(tags, data, output, parsed_args) - return output.getvalue() - - -@mock.patch('cliff.utils.terminal_width') -def test_table_formatter(tw): - tw.return_value = 80 - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', 'test\rcarriage\r\nreturn') - expected = '''\ -+-------+---------------+ -| Field | Value | -+-------+---------------+ -| a | A | -| b | B | -| c | C | -| d | test carriage | -| | return | -+-------+---------------+ -''' - assert expected == _table_tester_helper(c, d) - - -# Multi-line output when width is restricted to 42 columns -expected_ml_val = '''\ -+-------+--------------------------------+ -| Field | Value | -+-------+--------------------------------+ -| a | A | -| b | B | -| c | C | -| d | dddddddddddddddddddddddddddddd | -| | dddddddddddddddddddddddddddddd | -| | ddddddddddddddddd | -+-------+--------------------------------+ -''' - -# Multi-line output when width is restricted to 80 columns -expected_ml_80_val = '''\ -+-------+----------------------------------------------------------------------+ -| Field | Value | -+-------+----------------------------------------------------------------------+ -| a | A | -| b | B | -| c | C | -| d | dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd | -| | ddddddddd | -+-------+----------------------------------------------------------------------+ -''' # noqa - -# Single-line output, for when no line length restriction apply -expected_sl_val = '''\ -+-------+-------------------------------------------------------------------------------+ -| Field | Value | -+-------+-------------------------------------------------------------------------------+ -| a | A | -| b | B | -| c | C | -| d | ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd | -+-------+-------------------------------------------------------------------------------+ -''' # noqa - - -@mock.patch('cliff.utils.terminal_width') -def test_table_formatter_no_cli_param(tw): - tw.return_value = 80 - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', 'd' * 77) - assert expected_ml_80_val == _table_tester_helper(c, d, extra_args=args()) - - -@mock.patch('cliff.utils.terminal_width') -def test_table_formatter_cli_param(tw): - tw.return_value = 80 - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', 'd' * 77) - assert (expected_ml_val == - _table_tester_helper(c, d, extra_args=['--max-width', '42'])) - - -@mock.patch('cliff.utils.terminal_width') -def test_table_formatter_no_cli_param_unlimited_tw(tw): - tw.return_value = 0 - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', 'd' * 77) - # output should not be wrapped to multiple lines - assert expected_sl_val == _table_tester_helper(c, d, extra_args=args()) - - -@mock.patch('cliff.utils.terminal_width') -def test_table_formatter_cli_param_unlimited_tw(tw): - tw.return_value = 0 - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', 'd' * 77) - assert (expected_ml_val == - _table_tester_helper(c, d, extra_args=['--max-width', '42'])) - - -@mock.patch('cliff.utils.terminal_width') -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '666'}) -def test_table_formatter_cli_param_envvar_big(tw): - tw.return_value = 80 - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', 'd' * 77) - assert (expected_ml_val == - _table_tester_helper(c, d, extra_args=['--max-width', '42'])) - - -@mock.patch('cliff.utils.terminal_width') -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '23'}) -def test_table_formatter_cli_param_envvar_tiny(tw): - tw.return_value = 80 - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', 'd' * 77) - assert (expected_ml_val == - _table_tester_helper(c, d, extra_args=['--max-width', '42'])) - - -@mock.patch('cliff.utils.terminal_width') -def test_table_formatter_max_width(tw): - tw.return_value = 80 - c = ('field_name', 'a_really_long_field_name') - d = ('the value', 'a value significantly longer than the field') - expected = '''\ -+--------------------------+---------------------------------------------+ -| Field | Value | -+--------------------------+---------------------------------------------+ -| field_name | the value | -| a_really_long_field_name | a value significantly longer than the field | -+--------------------------+---------------------------------------------+ -''' - assert expected == _table_tester_helper(c, d) - - # resize value column - tw.return_value = 70 - expected = '''\ -+--------------------------+-----------------------------------------+ -| Field | Value | -+--------------------------+-----------------------------------------+ -| field_name | the value | -| a_really_long_field_name | a value significantly longer than the | -| | field | -+--------------------------+-----------------------------------------+ -''' - assert expected == _table_tester_helper(c, d) - - # resize both columns - tw.return_value = 50 - expected = '''\ -+-----------------------+------------------------+ -| Field | Value | -+-----------------------+------------------------+ -| field_name | the value | -| a_really_long_field_n | a value significantly | -| ame | longer than the field | -+-----------------------+------------------------+ -''' - assert expected == _table_tester_helper(c, d) - - # resize all columns limited by min_width=16 - tw.return_value = 10 - expected = '''\ -+------------------+------------------+ -| Field | Value | -+------------------+------------------+ -| field_name | the value | -| a_really_long_fi | a value | -| eld_name | significantly | -| | longer than the | -| | field | -+------------------+------------------+ -''' - assert expected == _table_tester_helper(c, d) - - -@mock.patch('cliff.utils.terminal_width') -def test_table_list_formatter(tw): - tw.return_value = 80 - c = ('a', 'b', 'c') - d1 = ('A', 'B', 'C') - d2 = ('D', 'E', 'test\rcarriage\r\nreturn') - data = [d1, d2] - expected = '''\ -+---+---+---------------+ -| a | b | c | -+---+---+---------------+ -| A | B | C | -| D | E | test carriage | -| | | return | -+---+---+---------------+ -''' - assert expected == _table_tester_helper(c, data) - - -@mock.patch('cliff.utils.terminal_width') -def test_table_formatter_formattable_column(tw): - tw.return_value = 0 - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', test_columns.FauxColumn(['the', 'value'])) - expected = '''\ -+-------+---------------------------------------------+ -| Field | Value | -+-------+---------------------------------------------+ -| a | A | -| b | B | -| c | C | -| d | I made this string myself: ['the', 'value'] | -+-------+---------------------------------------------+ -''' - assert expected == _table_tester_helper(c, d) - - -_col_names = ('one', 'two', 'three') -_col_data = [( - 'one one one one one', - 'two two two two', - 'three three')] - -_expected_mv = { - 80: '''\ -+---------------------+-----------------+-------------+ -| one | two | three | -+---------------------+-----------------+-------------+ -| one one one one one | two two two two | three three | -+---------------------+-----------------+-------------+ -''', - - 50: '''\ -+----------------+-----------------+-------------+ -| one | two | three | -+----------------+-----------------+-------------+ -| one one one | two two two two | three three | -| one one | | | -+----------------+-----------------+-------------+ -''', - - 47: '''\ -+---------------+---------------+-------------+ -| one | two | three | -+---------------+---------------+-------------+ -| one one one | two two two | three three | -| one one | two | | -+---------------+---------------+-------------+ -''', - - 45: '''\ -+--------------+--------------+-------------+ -| one | two | three | -+--------------+--------------+-------------+ -| one one one | two two two | three three | -| one one | two | | -+--------------+--------------+-------------+ -''', - - 40: '''\ -+------------+------------+------------+ -| one | two | three | -+------------+------------+------------+ -| one one | two two | three | -| one one | two two | three | -| one | | | -+------------+------------+------------+ -''', - - 10: '''\ -+----------+----------+----------+ -| one | two | three | -+----------+----------+----------+ -| one one | two two | three | -| one one | two two | three | -| one | | | -+----------+----------+----------+ -''', -} - - -@mock.patch('cliff.utils.terminal_width') -def test_table_list_formatter_formattable_column(tw): - tw.return_value = 80 - c = ('a', 'b', 'c') - d1 = ('A', 'B', test_columns.FauxColumn(['the', 'value'])) - data = [d1] - expected = '''\ -+---+---+---------------------------------------------+ -| a | b | c | -+---+---+---------------------------------------------+ -| A | B | I made this string myself: ['the', 'value'] | -+---+---+---------------------------------------------+ -''' - assert expected == _table_tester_helper(c, data) - - -@mock.patch('cliff.utils.terminal_width') -def test_table_list_formatter_max_width(tw): - # no resize - l = tw.return_value = 80 - assert _expected_mv[l] == _table_tester_helper(_col_names, _col_data) - - # resize 1 column - l = tw.return_value = 50 - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[l] == actual - assert len(actual.splitlines()[0]) == l - - # resize 2 columns - l = tw.return_value = 45 - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[l] == actual - assert len(actual.splitlines()[0]) == l - - # resize all columns - l = tw.return_value = 40 - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[l] == actual - assert len(actual.splitlines()[0]) == l - - # resize all columns limited by min_width=8 - l = tw.return_value = 10 - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[l] == actual - # 3 columns each 8 wide, plus table spacing and borders - expected_width = 11 * 3 + 1 - assert len(actual.splitlines()[0]) == expected_width - - -# Force a wide terminal by overriding its width with envvar -@mock.patch('cliff.utils.terminal_width') -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '666'}) -def test_table_list_formatter_max_width_and_envvar_max(tw): - # no resize - tw.return_value = 80 - assert _expected_mv[80] == _table_tester_helper(_col_names, _col_data) - - # resize 1 column - tw.return_value = 50 - assert _expected_mv[80] == _table_tester_helper(_col_names, _col_data) - - # resize 2 columns - tw.return_value = 45 - assert _expected_mv[80] == _table_tester_helper(_col_names, _col_data) - - # resize all columns - tw.return_value = 40 - assert _expected_mv[80] == _table_tester_helper(_col_names, _col_data) - - # resize all columns limited by min_width=8 - tw.return_value = 10 - assert _expected_mv[80] == _table_tester_helper(_col_names, _col_data) - - -# Force a narrow terminal by overriding its width with envvar -@mock.patch('cliff.utils.terminal_width') -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '47'}) -def test_table_list_formatter_max_width_and_envvar_mid(tw): - # no resize - tw.return_value = 80 - assert _expected_mv[47] == _table_tester_helper(_col_names, _col_data) - - # resize 1 column - tw.return_value = 50 - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[47] == actual - assert len(actual.splitlines()[0]) == 47 - - # resize 2 columns - tw.return_value = 45 - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[47] == actual - assert len(actual.splitlines()[0]) == 47 - - # resize all columns - tw.return_value = 40 - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[47] == actual - assert len(actual.splitlines()[0]) == 47 - - # resize all columns limited by min_width=8 - tw.return_value = 10 - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[47] == actual - assert len(actual.splitlines()[0]) == 47 - - -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '80'}) -def test_table_list_formatter_env_maxwidth_noresize(): - # no resize - assert _expected_mv[80] == _table_tester_helper(_col_names, _col_data) - - -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '50'}) -def test_table_list_formatter_env_maxwidth_resize_one(): - # resize 1 column - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[50] == actual - assert len(actual.splitlines()[0]) == 50 - - -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '45'}) -def test_table_list_formatter_env_maxwidth_resize_two(): - # resize 2 columns - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[45] == actual - assert len(actual.splitlines()[0]) == 45 - - -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '40'}) -def test_table_list_formatter_env_maxwidth_resize_all(): - # resize all columns - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[40] == actual - assert len(actual.splitlines()[0]) == 40 - - -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '8'}) -def test_table_list_formatter_env_maxwidth_resize_all_tiny(): - # resize all columns limited by min_width=8 - actual = _table_tester_helper(_col_names, _col_data) - assert _expected_mv[10] == actual - # 3 columns each 8 wide, plus table spacing and borders - expected_width = 11 * 3 + 1 - assert len(actual.splitlines()[0]) == expected_width - - -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '42'}) -def test_table_list_formatter_env_maxwidth_args_big(): - assert _expected_mv[80] == _table_tester_helper(_col_names, _col_data, - extra_args=args(666)) - - -@mock.patch.dict(os.environ, {'CLIFF_MAX_TERM_WIDTH': '42'}) -def test_table_list_formatter_env_maxwidth_args_tiny(): - assert _expected_mv[40] == _table_tester_helper(_col_names, _col_data, - extra_args=args(40)) - - -@mock.patch('cliff.utils.terminal_width') -def test_table_list_formatter_empty(tw): - tw.return_value = 80 - c = ('a', 'b', 'c') - data = [] - expected = '\n' - assert expected == _table_tester_helper(c, data) - - -@mock.patch('cliff.utils.terminal_width') -def test_table_list_formatter_empty_table(tw): - tw.return_value = 80 - c = ('a', 'b', 'c') - data = [] - expected = '''\ -+---+---+---+ -| a | b | c | -+---+---+---+ -+---+---+---+ -''' - assert expected == _table_tester_helper(c, data, - extra_args=['--print-empty']) - - -def test_field_widths(): - tf = table.TableFormatter - assert { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 10 - } == tf._field_widths( - ('a', 'b', 'c', 'd'), - '+---+----+-----+------------+') - - -def test_field_widths_zero(): - tf = table.TableFormatter - assert { - 'a': 0, - 'b': 0, - 'c': 0 - } == tf._field_widths( - ('a', 'b', 'c'), - '+--+-++') - - -def test_width_info(): - tf = table.TableFormatter - assert (49, 4) == (tf._width_info(80, 10)) - assert (76, 76) == (tf._width_info(80, 1)) - assert (79, 0) == (tf._width_info(80, 0)) - assert (0, 0) == (tf._width_info(0, 80)) diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_value.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_value.py deleted file mode 100644 index f704b08..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_value.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six - -from cliff.formatters import value -from cliff.tests import test_columns - - -def test_value_formatter(): - sf = value.ValueFormatter() - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', '"no escape me"') - expected = 'A\nB\nC\n"no escape me"\n' - output = six.StringIO() - sf.emit_one(c, d, output, None) - actual = output.getvalue() - assert expected == actual - - -def test_value_formatter_formattable_column(): - sf = value.ValueFormatter() - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', test_columns.FauxColumn(['the', 'value'])) - expected = "A\nB\nC\n['the', 'value']\n" - output = six.StringIO() - sf.emit_one(c, d, output, None) - actual = output.getvalue() - assert expected == actual - - -def test_value_list_formatter(): - sf = value.ValueFormatter() - c = ('a', 'b', 'c') - d1 = ('A', 'B', 'C') - d2 = ('D', 'E', 'F') - data = [d1, d2] - expected = 'A B C\nD E F\n' - output = six.StringIO() - sf.emit_list(c, data, output, None) - actual = output.getvalue() - assert expected == actual - - -def test_value_list_formatter_formattable_column(): - sf = value.ValueFormatter() - c = ('a', 'b', 'c') - d1 = ('A', 'B', test_columns.FauxColumn(['the', 'value'])) - data = [d1] - expected = "A B ['the', 'value']\n" - output = six.StringIO() - sf.emit_list(c, data, output, None) - actual = output.getvalue() - assert expected == actual diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_yaml.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_yaml.py deleted file mode 100644 index 61db5d8..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_formatters_yaml.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import six -import yaml - -from cliff.formatters import yaml_format -from cliff.tests import test_columns - -import mock - - -def test_yaml_format_one(): - sf = yaml_format.YAMLFormatter() - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', '"escape me"') - expected = { - 'a': 'A', - 'b': 'B', - 'c': 'C', - 'd': '"escape me"' - } - output = six.StringIO() - args = mock.Mock() - sf.emit_one(c, d, output, args) - actual = yaml.safe_load(output.getvalue()) - assert expected == actual - - -def test_yaml_format_formattablecolumn_one(): - sf = yaml_format.YAMLFormatter() - c = ('a', 'b', 'c', 'd') - d = ('A', 'B', 'C', test_columns.FauxColumn(['the', 'value'])) - expected = { - 'a': 'A', - 'b': 'B', - 'c': 'C', - 'd': ['the', 'value'], - } - args = mock.Mock() - sf.add_argument_group(args) - - args.noindent = True - output = six.StringIO() - sf.emit_one(c, d, output, args) - value = output.getvalue() - print(len(value.splitlines())) - actual = yaml.safe_load(output.getvalue()) - assert expected == actual - - -def test_yaml_format_list(): - sf = yaml_format.YAMLFormatter() - c = ('a', 'b', 'c') - d = ( - ('A1', 'B1', 'C1'), - ('A2', 'B2', 'C2'), - ('A3', 'B3', 'C3') - ) - expected = [ - {'a': 'A1', 'b': 'B1', 'c': 'C1'}, - {'a': 'A2', 'b': 'B2', 'c': 'C2'}, - {'a': 'A3', 'b': 'B3', 'c': 'C3'} - ] - output = six.StringIO() - args = mock.Mock() - sf.add_argument_group(args) - sf.emit_list(c, d, output, args) - actual = yaml.safe_load(output.getvalue()) - assert expected == actual - - -def test_yaml_format_formattablecolumn_list(): - sf = yaml_format.YAMLFormatter() - c = ('a', 'b', 'c') - d = ( - ('A1', 'B1', test_columns.FauxColumn(['the', 'value'])), - ) - expected = [ - {'a': 'A1', 'b': 'B1', 'c': ['the', 'value']}, - ] - args = mock.Mock() - sf.add_argument_group(args) - - args.noindent = True - output = six.StringIO() - sf.emit_list(c, d, output, args) - actual = yaml.safe_load(output.getvalue()) - assert expected == actual diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_help.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_help.py deleted file mode 100644 index 23659a2..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_help.py +++ /dev/null @@ -1,180 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -try: - from StringIO import StringIO -except: - from io import StringIO -import os -import sys - -import mock - -from cliff import app as application -from cliff import commandmanager -from cliff import help -from cliff.tests import utils - - -def test_show_help_for_command(): - # FIXME(dhellmann): Are commands tied too closely to the app? Or - # do commands know too much about apps by using them to get to the - # command manager? - stdout = StringIO() - app = application.App('testing', '1', - utils.TestCommandManager(utils.TEST_NAMESPACE), - stdout=stdout) - app.NAME = 'test' - help_cmd = help.HelpCommand(app, mock.Mock()) - parser = help_cmd.get_parser('test') - parsed_args = parser.parse_args(['one']) - try: - help_cmd.run(parsed_args) - except SystemExit: - pass - assert stdout.getvalue() == 'TestParser' - - -def test_list_matching_commands(): - # FIXME(dhellmann): Are commands tied too closely to the app? Or - # do commands know too much about apps by using them to get to the - # command manager? - stdout = StringIO() - app = application.App('testing', '1', - utils.TestCommandManager(utils.TEST_NAMESPACE), - stdout=stdout) - app.NAME = 'test' - help_cmd = help.HelpCommand(app, mock.Mock()) - parser = help_cmd.get_parser('test') - parsed_args = parser.parse_args(['t']) - try: - help_cmd.run(parsed_args) - except SystemExit: - pass - help_output = stdout.getvalue() - assert 'Command "t" matches:' in help_output - assert 'three word command\n two words\n' in help_output - - -def test_list_matching_commands_no_match(): - # FIXME(dhellmann): Are commands tied too closely to the app? Or - # do commands know too much about apps by using them to get to the - # command manager? - stdout = StringIO() - app = application.App('testing', '1', - utils.TestCommandManager(utils.TEST_NAMESPACE), - stdout=stdout) - app.NAME = 'test' - help_cmd = help.HelpCommand(app, mock.Mock()) - parser = help_cmd.get_parser('test') - parsed_args = parser.parse_args(['z']) - try: - help_cmd.run(parsed_args) - except SystemExit: - pass - except ValueError: - pass - else: - assert False, 'Should have seen a ValueError' - - -def test_show_help_for_help(): - # FIXME(dhellmann): Are commands tied too closely to the app? Or - # do commands know too much about apps by using them to get to the - # command manager? - stdout = StringIO() - app = application.App('testing', '1', - utils.TestCommandManager(utils.TEST_NAMESPACE), - stdout=stdout) - app.NAME = 'test' - app.options = mock.Mock() - help_cmd = help.HelpCommand(app, mock.Mock()) - parser = help_cmd.get_parser('test') - parsed_args = parser.parse_args([]) - try: - help_cmd.run(parsed_args) - except SystemExit: - pass - help_text = stdout.getvalue() - basecommand = os.path.split(sys.argv[0])[1] - assert 'usage: %s [--version]' % basecommand in help_text - assert 'optional arguments:\n --version' in help_text - expected = ( - ' one Test command.\n' - ' three word command Test command.\n' - ) - assert expected in help_text - - -def test_list_deprecated_commands(): - # FIXME(dhellmann): Are commands tied too closely to the app? Or - # do commands know too much about apps by using them to get to the - # command manager? - stdout = StringIO() - app = application.App('testing', '1', - utils.TestCommandManager(utils.TEST_NAMESPACE), - stdout=stdout) - app.NAME = 'test' - try: - app.run(['--help']) - except SystemExit: - pass - help_output = stdout.getvalue() - assert 'two words' in help_output - assert 'three word command' in help_output - assert 'old cmd' not in help_output - - -@mock.patch.object(commandmanager.EntryPointWrapper, 'load', - side_effect=Exception('Could not load EntryPoint')) -def test_show_help_with_ep_load_fail(mock_load): - stdout = StringIO() - app = application.App('testing', '1', - utils.TestCommandManager(utils.TEST_NAMESPACE), - stdout=stdout) - app.NAME = 'test' - app.options = mock.Mock() - app.options.debug = False - help_cmd = help.HelpCommand(app, mock.Mock()) - parser = help_cmd.get_parser('test') - parsed_args = parser.parse_args([]) - try: - help_cmd.run(parsed_args) - except SystemExit: - pass - help_output = stdout.getvalue() - assert 'Commands:' in help_output - assert 'Could not load' in help_output - assert 'Exception: Could not load EntryPoint' not in help_output - - -@mock.patch.object(commandmanager.EntryPointWrapper, 'load', - side_effect=Exception('Could not load EntryPoint')) -def test_show_help_print_exc_with_ep_load_fail(mock_load): - stdout = StringIO() - app = application.App('testing', '1', - utils.TestCommandManager(utils.TEST_NAMESPACE), - stdout=stdout) - app.NAME = 'test' - app.options = mock.Mock() - app.options.debug = True - help_cmd = help.HelpCommand(app, mock.Mock()) - parser = help_cmd.get_parser('test') - parsed_args = parser.parse_args([]) - try: - help_cmd.run(parsed_args) - except SystemExit: - pass - help_output = stdout.getvalue() - assert 'Commands:' in help_output - assert 'Could not load' in help_output - assert 'Exception: Could not load EntryPoint' in help_output diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_interactive.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_interactive.py deleted file mode 100644 index 7d9667e..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_interactive.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- encoding: utf-8 -*- -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from cliff.interactive import InteractiveApp - - -class FakeApp(object): - NAME = 'Fake' - - -def make_interactive_app(*command_names): - fake_command_manager = [(x, None) for x in command_names] - return InteractiveApp(FakeApp, fake_command_manager, - stdin=None, stdout=None) - - -def _test_completenames(expecteds, prefix): - app = make_interactive_app('hips', 'hippo', 'nonmatching') - assert set(app.completenames(prefix)) == set(expecteds) - - -def test_cmd2_completenames(): - # cmd2.Cmd define do_help method - _test_completenames(['help'], 'he') - - -def test_cliff_completenames(): - _test_completenames(['hips', 'hippo'], 'hip') - - -def test_no_completenames(): - _test_completenames([], 'taz') - - -def test_both_completenames(): - # cmd2.Cmd define do_hi and do_history methods - _test_completenames(['hi', 'history', 'hips', 'hippo'], 'hi') - - -def _test_completedefault(expecteds, line, begidx): - command_names = set(['show file', 'show folder', 'show long', 'list all']) - app = make_interactive_app(*command_names) - observeds = app.completedefault(None, line, begidx, None) - assert set(observeds) == set(expecteds) - assert set([line[:begidx] + x for x in observeds]) <= command_names - - -def test_empty_text_completedefault(): - # line = 'show ' + begidx = 5 implies text = '' - _test_completedefault(['file', 'folder', ' long'], 'show ', 5) - - -def test_nonempty_text_completedefault2(): - # line = 'show f' + begidx = 6 implies text = 'f' - _test_completedefault(['file', 'folder'], 'show f', 5) - - -def test_long_completedefault(): - _test_completedefault(['long'], 'show ', 6) - - -def test_no_completedefault(): - _test_completedefault([], 'taz ', 4) diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_lister.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_lister.py deleted file mode 100644 index f2e4a0d..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_lister.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import weakref - -from cliff import lister - -import mock - - -class FauxFormatter(object): - - def __init__(self): - self.args = [] - self.obj = weakref.proxy(self) - - def emit_list(self, columns, data, stdout, args): - self.args.append((columns, data)) - - -class ExerciseLister(lister.Lister): - - def _load_formatter_plugins(self): - return { - 'test': FauxFormatter(), - } - - def take_action(self, parsed_args): - return ( - parsed_args.columns, - [('a', 'A'), ('b', 'B')], - ) - - -def test_formatter_args(): - app = mock.Mock() - test_lister = ExerciseLister(app, []) - - parsed_args = mock.Mock() - parsed_args.columns = ('Col1', 'Col2') - parsed_args.formatter = 'test' - - test_lister.run(parsed_args) - f = test_lister._formatter_plugins['test'] - assert len(f.args) == 1 - args = f.args[0] - assert args[0] == list(parsed_args.columns) - data = list(args[1]) - assert data == [['a', 'A'], ['b', 'B']] - - -def test_no_exist_column(): - test_lister = ExerciseLister(mock.Mock(), []) - parsed_args = mock.Mock() - parsed_args.columns = ('no_exist_column',) - parsed_args.formatter = 'test' - with mock.patch.object(test_lister, 'take_action') as mock_take_action: - mock_take_action.return_value = (('Col1', 'Col2', 'Col3'), []) - try: - test_lister.run(parsed_args) - except ValueError: - pass - else: - assert False, 'Should have had an exception' diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_show.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_show.py deleted file mode 100644 index 9e46c54..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_show.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import weakref - -from cliff import show - -import mock - - -class FauxFormatter(object): - - def __init__(self): - self.args = [] - self.obj = weakref.proxy(self) - - def emit_one(self, columns, data, stdout, args): - self.args.append((columns, data)) - - -class ExerciseShowOne(show.ShowOne): - - def _load_formatter_plugins(self): - return { - 'test': FauxFormatter(), - } - - def take_action(self, parsed_args): - return ( - parsed_args.columns, - [('a', 'A'), ('b', 'B')], - ) - - -def test_formatter_args(): - app = mock.Mock() - test_show = ExerciseShowOne(app, []) - - parsed_args = mock.Mock() - parsed_args.columns = ('Col1', 'Col2') - parsed_args.formatter = 'test' - - test_show.run(parsed_args) - f = test_show._formatter_plugins['test'] - assert len(f.args) == 1 - args = f.args[0] - assert args[0] == list(parsed_args.columns) - data = list(args[1]) - assert data == [('a', 'A'), ('b', 'B')] - - -def test_dict2columns(): - app = mock.Mock() - test_show = ExerciseShowOne(app, []) - d = {'a': 'A', 'b': 'B', 'c': 'C'} - expected = [('a', 'b', 'c'), ('A', 'B', 'C')] - actual = list(test_show.dict2columns(d)) - assert expected == actual - - -def test_no_exist_column(): - test_show = ExerciseShowOne(mock.Mock(), []) - parsed_args = mock.Mock() - parsed_args.columns = ('no_exist_column',) - parsed_args.formatter = 'test' - with mock.patch.object(test_show, 'take_action') as mock_take_action: - mock_take_action.return_value = (('Col1', 'Col2', 'Col3'), []) - try: - test_show.run(parsed_args) - except ValueError: - pass - else: - assert False, 'Should have had an exception' diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_utils.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_utils.py deleted file mode 100644 index 23c46c4..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/test_utils.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import os -import struct -import sys - -import mock -import nose - -from cliff import utils - - -def test_utils_terminal_width(): - width = utils.terminal_width(sys.stdout) - # Results are specific to the execution environment, so only assert - # that no error is raised. - assert width is None or isinstance(width, int) - - -@mock.patch('cliff.utils.os') -def test_utils_terminal_width_get_terminal_size(mock_os): - if not hasattr(os, 'get_terminal_size'): - raise nose.SkipTest('only needed for python 3.3 onwards') - ts = os.terminal_size((10, 5)) - mock_os.get_terminal_size.return_value = ts - width = utils.terminal_width(sys.stdout) - assert width == 10 - - mock_os.get_terminal_size.side_effect = OSError() - width = utils.terminal_width(sys.stdout) - assert width is None - - -@mock.patch('fcntl.ioctl') -def test_utils_terminal_width_ioctl(mock_ioctl): - if hasattr(os, 'get_terminal_size'): - raise nose.SkipTest('only needed for python 3.2 and before') - mock_ioctl.return_value = struct.pack('hhhh', 57, 101, 0, 0) - width = utils.terminal_width(sys.stdout) - assert width == 101 - - mock_ioctl.side_effect = IOError() - width = utils.terminal_width(sys.stdout) - assert width is None - - -@mock.patch('cliff.utils.ctypes') -@mock.patch('sys.platform', 'win32') -def test_utils_terminal_width_windows(mock_ctypes): - if hasattr(os, 'get_terminal_size'): - raise nose.SkipTest('only needed for python 3.2 and before') - - mock_ctypes.create_string_buffer.return_value.raw = struct.pack( - 'hhhhHhhhhhh', 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - mock_ctypes.windll.kernel32.GetStdHandle.return_value = -11 - mock_ctypes.windll.kernel32.GetConsoleScreenBufferInfo.return_value = 1 - - width = utils.terminal_width(sys.stdout) - assert width == 101 - - mock_ctypes.windll.kernel32.GetConsoleScreenBufferInfo.return_value = 0 - - width = utils.terminal_width(sys.stdout) - assert width is None - - width = utils.terminal_width('foo') - assert width is None diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/utils.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/utils.py deleted file mode 100644 index b9cdba3..0000000 --- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/tests/utils.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from cliff.command import Command -from cliff.commandmanager import CommandManager - -TEST_NAMESPACE = 'cliff.test' - - -class TestParser(object): - - def print_help(self, stdout): - stdout.write('TestParser') - - -class TestCommand(Command): - "Test command." - - def get_parser(self, ignore): - # Make it look like this class is the parser - # so parse_args() is called. - return TestParser() - - def take_action(self, args): - return - - -class TestDeprecatedCommand(TestCommand): - - deprecated = True - - -class TestCommandManager(CommandManager): - - def load_commands(self, namespace): - if namespace == TEST_NAMESPACE: - for key in ('one', 'two words', 'three word command'): - self.add_command(key, TestCommand) - self.add_command('old cmd', TestDeprecatedCommand) -- cgit 1.2.3-korg