Merge "Make create commands cut long output"

This commit is contained in:
Jenkins 2015-05-27 07:09:20 +00:00 committed by Gerrit Code Review
commit 5d1dc50924
4 changed files with 43 additions and 2 deletions

View File

@ -113,7 +113,7 @@ class Create(base.MistralLister):
raise RuntimeError("Provide action definition file.")
def _get_format_function(self):
return format
return format_list
def _get_resources(self, parsed_args):
return actions.ActionManager(self.app.client).create(

View File

@ -102,7 +102,7 @@ class Create(base.MistralLister):
return parser
def _get_format_function(self):
return format
return format_list
def _validate_parsed_args(self, parsed_args):
if not parsed_args.definition:

View File

@ -15,9 +15,11 @@
#
import mock
import six
from mistralclient.api.v2 import actions
from mistralclient.commands.v2 import actions as action_cmd
from mistralclient.commands.v2 import base as cmd_base
from mistralclient.tests.unit import base
@ -60,6 +62,25 @@ class TestCLIActionsV2(base.BaseCommandTest):
result[1]
)
@mock.patch('argparse.open', create=True)
@mock.patch('mistralclient.api.v2.actions.ActionManager.create')
def test_create_long_input(self, mock, mock_open):
action_long_input_dict = ACTION_DICT.copy()
long_input = ', '.join(
['var%s' % i for i in six.moves.xrange(10)]
)
action_long_input_dict['input'] = long_input
workflow_long_input = actions.Action(mock, action_long_input_dict)
mock.return_value = (workflow_long_input,)
result = self.call(action_cmd.Create, app_args=['1.txt'])
self.assertEqual(
[('a', True, cmd_base.cut(long_input),
'My cool action', 'test', '1', '1')],
result[1]
)
@mock.patch('argparse.open', create=True)
@mock.patch('mistralclient.api.v2.actions.ActionManager.update')
def test_update(self, mock, mock_open):

View File

@ -14,8 +14,10 @@
# limitations under the License.
import mock
import six
from mistralclient.api.v2 import workflows
from mistralclient.commands.v2 import base as cmd_base
from mistralclient.commands.v2 import workflows as workflow_cmd
from mistralclient import exceptions as exc
from mistralclient.tests.unit import base
@ -54,6 +56,24 @@ class TestCLIWorkflowsV2(base.BaseCommandTest):
self.assertEqual([('a', 'a, b', 'param', '1', '1')], result[1])
@mock.patch('argparse.open', create=True)
@mock.patch('mistralclient.api.v2.workflows.WorkflowManager.create')
def test_create_long_input(self, mock, mock_open):
wf_long_input_dict = WORKFLOW_DICT.copy()
long_input = ', '.join(
['var%s' % i for i in six.moves.xrange(10)]
)
wf_long_input_dict['input'] = long_input
workflow_long_input = workflows.Workflow(mock, wf_long_input_dict)
mock.return_value = (workflow_long_input,)
result = self.call(workflow_cmd.Create, app_args=['1.txt'])
self.assertEqual(
[('a', 'a, b', cmd_base.cut(long_input), '1', '1')],
result[1]
)
@mock.patch('argparse.open', create=True)
@mock.patch('mistralclient.api.v2.workflows.WorkflowManager.update')
def test_update(self, mock, mock_open):