diff options
author | Taseer Ahmed <taseer94@gmail.com> | 2017-01-22 12:04:46 +0500 |
---|---|---|
committer | Taseer Ahmed <taseer94@gmail.com> | 2017-01-22 12:16:13 +0500 |
commit | 3424659963f472ecfbf1e3c9e08945de4b34e36c (patch) | |
tree | bc9193f20213e5df9eea52735ac93610d32746b4 | |
parent | e835a660789c2f152750308fa1eeb1b5e970a257 (diff) |
Plan module draft
JIRA: QTIP-205
JIRA: QTIP-188
Change-Id: Ia871191851d25e1986834f8a7efdbeb8a8d87ec3
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
-rw-r--r-- | qtip/cli/commands/cmd_plan.py | 45 | ||||
-rw-r--r-- | tests/unit/cli/test_plan.py | 31 |
2 files changed, 54 insertions, 22 deletions
diff --git a/qtip/cli/commands/cmd_plan.py b/qtip/cli/commands/cmd_plan.py index 6f622e5a..0c0a3c12 100644 --- a/qtip/cli/commands/cmd_plan.py +++ b/qtip/cli/commands/cmd_plan.py @@ -1,4 +1,4 @@ -############################################################################# +############################################################################## # Copyright (c) 2016 ZTE Corp and others. # # All rights reserved. This program and the accompanying materials @@ -7,38 +7,39 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## + import click -from prettytable import PrettyTable -from qtip.loader.plan import Plan +from qtip.cli.entry import Context + + +pass_context = click.make_pass_decorator(Context, ensure=False) @click.group() -def cli(): +@pass_context +def cli(ctx): + ''' Bechmarking Plan ''' pass -@cli.group() -def plan_cmd(): +@cli.command('init', help='Initialize Environment') +@click.option('--inst_type', prompt='Installer Type') +@click.option('--inst_ip', prompt='Installer IP') +@click.option('--ext_net', prompt='Openstack External Network') +@pass_context +def init(ctx, inst_type, inst_ip, ext_net): pass -@plan_cmd.command('list', help='List the different TestPlans.') -def list_all(): - plans = Plan.list_all() - table = PrettyTable(["Testplans"]) - table.align = 'l' - for plan in plans: - table.add_row([plan['name']]) - click.echo(table) +@cli.command('list', help='List the Plans') +@pass_context +def list(ctx): + pass -@plan_cmd.command('show', help='Show details of specified TestPlan.') +@cli.command('run', help='Execute a Plan') @click.argument('name') -def show(name): - plan = Plan(name) - results = plan.content() - table = PrettyTable(["Name", "Description"]) - table.align = 'l' - table.add_row([results['name'], results['description']]) - click.echo(table) +@pass_context +def run(ctx, name): + pass diff --git a/tests/unit/cli/test_plan.py b/tests/unit/cli/test_plan.py new file mode 100644 index 00000000..3ce3766e --- /dev/null +++ b/tests/unit/cli/test_plan.py @@ -0,0 +1,31 @@ +############################################################### +# Copyright (c) 2016 ZTE Corp and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import pytest +from click.testing import CliRunner + +from qtip.cli.entry import cli + + +@pytest.fixture() +def runner(): + return CliRunner() + + +def test_list(runner): + result = runner.invoke(cli, ['plan', 'list']) + assert result.output == '' + + +def test_run(runner): + result = runner.invoke(cli, ['plan', 'run', 'fake-plan']) + assert result.output == '' + + result = runner.invoke(cli, ['plan', 'run']) + assert 'Missing argument "name".' in result.output |