def test_check_reformat_parameter_no_equals_first(): ctx = Mock(side_effect=Exception("failed")) param = ['thisthat', 'some=another'] try: input_checks.check_reformat_parameter(ctx, param) except Exception: pass # py 3.6: ctx.fail.assert_called() assert 'call.fail(' in str(ctx.mock_calls[0])
def test_check_reformat_parameter_valid(): ctx = Mock(side_effect=Exception("failed")) param = ['this=that'] input_checks.check_reformat_parameter(ctx, param) param = [] input_checks.check_reformat_parameter(ctx, param) param = ['this=that', 'some=another'] o_params = input_checks.check_reformat_parameter(ctx, param) assert 'this' in o_params assert 'some' in o_params assert 'that' not in o_params assert 'another' not in o_params assert o_params['this'] == 'that' assert o_params['some'] == 'another' ctx.fail.assert_not_called()
def create_action(ctx, action_name, param): check_action_command(ctx, action_name) if not param and action_name is 'redeploy_server': ctx.fail('At least one parameter must be specified using ' '--param="<parameter>" with action redeploy_server') else: param = check_reformat_parameter(ctx, param) click.echo( CreateAction(ctx, action_name, param).invoke_and_return_resp())