Metric module outline 71/26871/6
authorTaseer Ahmed <taseer94@gmail.com>
Mon, 9 Jan 2017 15:41:23 +0000 (20:41 +0500)
committerTaseer Ahmed <taseer94@gmail.com>
Tue, 17 Jan 2017 14:02:31 +0000 (19:02 +0500)
Change-Id: Id95b07f1c0821ae0883c761fdf8f507afba4e5c0
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
qtip/cli/commands/cmd_metric.py [new file with mode: 0644]
qtip/cli/commands/cmd_perftest.py [deleted file]
tests/unit/cli/test_metric.py [new file with mode: 0644]

diff --git a/qtip/cli/commands/cmd_metric.py b/qtip/cli/commands/cmd_metric.py
new file mode 100644 (file)
index 0000000..7f5c18d
--- /dev/null
@@ -0,0 +1,33 @@
+##############################################################################
+# 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 click
+
+from qtip.cli.entry import Context
+
+pass_context = click.make_pass_decorator(Context, ensure=False)
+
+
+@click.group()
+@pass_context
+def cli(ctx):
+    ''' Performance Metrics Group '''
+    pass
+
+
+@cli.command('list', help='List all the Metric Groups')
+@pass_context
+def cmd_list(ctx):
+    pass
+
+
+@cli.command('run', help='Run tests to collect Performance Metrics')
+@pass_context
+def cmd_run(ctx):
+    pass
diff --git a/qtip/cli/commands/cmd_perftest.py b/qtip/cli/commands/cmd_perftest.py
deleted file mode 100644 (file)
index 129ee2d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-##############################################################################
-# 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
-##############################################################################
-
-from prettytable import PrettyTable
-import yaml
-import click
-import os
-from qtip.cli import helper
-
-
-class PerfTest:
-
-    def __init__(self):
-        self.path = os.path.join(helper.fetch_root(), 'perftest/summary')
-
-    def list(self):
-        table = PrettyTable(["Name", "Description"])
-        table.align = 'l'
-        with open(self.path) as tests:
-            line = tests.read()
-            data = yaml.safe_load(line)['test_cases']
-            for i in range(0, len(data)):
-                points = data[i]
-                table.add_row([points['name'], points['description']])
-        click.echo(table)
-
-    def run(self):
-        click.echo("Run a perftest")
-
-
-@click.group()
-def cli():
-    pass
-
-
-@cli.group()
-@click.pass_context
-def perftest(ctx):
-    pass
-
-
-_perftest = PerfTest()
-
-
-@perftest.command("list", help="Lists all perftest benchmarks.")
-def list():
-    _perftest.list()
-
-
-@perftest.command("run", help="Executes a single perftest benchmark.")
-def execute():
-    _perftest.run()
diff --git a/tests/unit/cli/test_metric.py b/tests/unit/cli/test_metric.py
new file mode 100644 (file)
index 0000000..ed10689
--- /dev/null
@@ -0,0 +1,28 @@
+###############################################################
+# 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.commands.cmd_metric import cli
+
+
+@pytest.fixture()
+def runner():
+    return CliRunner()
+
+
+def test_list(runner):
+    result = runner.invoke(cli, ['list'])
+    assert result.output == ''
+
+
+def test_run(runner):
+    result = runner.invoke(cli, ['run'])
+    assert result.output == ''