From fc95a8868d1c4168cb900bc7e2004b557f757bf9 Mon Sep 17 00:00:00 2001 From: Yujun Zhang Date: Fri, 17 Feb 2017 18:39:28 +0800 Subject: Clean up tests folder - remove __init__.py as recommended in pytest docs[1] - rename cli test files for a consistent naming style - remove empty test files [1]: http://docs.pytest.org/en/latest/goodpractices.html#choosing-a-test-layout-import-rules Change-Id: Idfb5d8a8fb7a590ef988a761991b8e313089e9bc Signed-off-by: Yujun Zhang --- tests/__init__.py | 18 ---------------- tests/unit/__init__.py | 0 tests/unit/cli/__init__.py | 0 tests/unit/cli/cmd_metric_test.py | 31 +++++++++++++++++++++++++++ tests/unit/cli/cmd_plan_test.py | 31 +++++++++++++++++++++++++++ tests/unit/cli/cmd_qpi_test.py | 31 +++++++++++++++++++++++++++ tests/unit/cli/options_test.py | 32 ++++++++++++++++++++++++++++ tests/unit/cli/test_metric.py | 31 --------------------------- tests/unit/cli/test_options.py | 32 ---------------------------- tests/unit/cli/test_plan.py | 31 --------------------------- tests/unit/cli/test_qpi.py | 31 --------------------------- tests/unit/collector/transformer/__init__.py | 0 tests/unit/loader/__init__.py | 0 tests/unit/runner/__init__.py | 0 14 files changed, 125 insertions(+), 143 deletions(-) delete mode 100644 tests/__init__.py delete mode 100644 tests/unit/__init__.py delete mode 100644 tests/unit/cli/__init__.py create mode 100644 tests/unit/cli/cmd_metric_test.py create mode 100644 tests/unit/cli/cmd_plan_test.py create mode 100644 tests/unit/cli/cmd_qpi_test.py create mode 100644 tests/unit/cli/options_test.py delete mode 100644 tests/unit/cli/test_metric.py delete mode 100644 tests/unit/cli/test_options.py delete mode 100644 tests/unit/cli/test_plan.py delete mode 100644 tests/unit/cli/test_qpi.py delete mode 100644 tests/unit/collector/transformer/__init__.py delete mode 100644 tests/unit/loader/__init__.py delete mode 100644 tests/unit/runner/__init__.py diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index d6d2dee5..00000000 --- a/tests/__init__.py +++ /dev/null @@ -1,18 +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 os import path - - -class BaseTest(object): - PATH = path.abspath(path.join(path.dirname(__file__), 'data')) - - @classmethod - def abspath(cls, name): - return path.join(cls.PATH, name) diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/unit/cli/__init__.py b/tests/unit/cli/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/unit/cli/cmd_metric_test.py b/tests/unit/cli/cmd_metric_test.py new file mode 100644 index 00000000..239da96e --- /dev/null +++ b/tests/unit/cli/cmd_metric_test.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, ['metric', 'list']) + assert result.output == '' + + +def test_run(runner): + result = runner.invoke(cli, ['metric', 'run', 'fake-metric']) + assert result.output == '' + + result = runner.invoke(cli, ['metric', 'run']) + assert 'Missing argument "name".' in result.output diff --git a/tests/unit/cli/cmd_plan_test.py b/tests/unit/cli/cmd_plan_test.py new file mode 100644 index 00000000..3ce3766e --- /dev/null +++ b/tests/unit/cli/cmd_plan_test.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 diff --git a/tests/unit/cli/cmd_qpi_test.py b/tests/unit/cli/cmd_qpi_test.py new file mode 100644 index 00000000..992c85d7 --- /dev/null +++ b/tests/unit/cli/cmd_qpi_test.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, ['qpi', 'list']) + assert result.output == '' + + +def test_run(runner): + result = runner.invoke(cli, ['qpi', 'run', 'fake-qpi']) + assert result.output == '' + + result = runner.invoke(cli, ['qpi', 'run']) + assert 'Missing argument "name".' in result.output diff --git a/tests/unit/cli/options_test.py b/tests/unit/cli/options_test.py new file mode 100644 index 00000000..f9472814 --- /dev/null +++ b/tests/unit/cli/options_test.py @@ -0,0 +1,32 @@ +############################################################### +# 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 + + +class TestClass(object): + + @pytest.fixture() + def runner(self): + return CliRunner() + + def test_verbose(self, runner): + result = runner.invoke(cli, ['-v']) + assert result.output == '' + + def test_version(self, runner): + result = runner.invoke(cli, ['--version']) + assert 'dev' in result.output + + def test_debug(self, runner): + result = runner.invoke(cli, ['-d']) + assert '' in result.output diff --git a/tests/unit/cli/test_metric.py b/tests/unit/cli/test_metric.py deleted file mode 100644 index 239da96e..00000000 --- a/tests/unit/cli/test_metric.py +++ /dev/null @@ -1,31 +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 -############################################################################## - -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, ['metric', 'list']) - assert result.output == '' - - -def test_run(runner): - result = runner.invoke(cli, ['metric', 'run', 'fake-metric']) - assert result.output == '' - - result = runner.invoke(cli, ['metric', 'run']) - assert 'Missing argument "name".' in result.output diff --git a/tests/unit/cli/test_options.py b/tests/unit/cli/test_options.py deleted file mode 100644 index f9472814..00000000 --- a/tests/unit/cli/test_options.py +++ /dev/null @@ -1,32 +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 -############################################################################## - -import pytest -from click.testing import CliRunner - -from qtip.cli.entry import cli - - -class TestClass(object): - - @pytest.fixture() - def runner(self): - return CliRunner() - - def test_verbose(self, runner): - result = runner.invoke(cli, ['-v']) - assert result.output == '' - - def test_version(self, runner): - result = runner.invoke(cli, ['--version']) - assert 'dev' in result.output - - def test_debug(self, runner): - result = runner.invoke(cli, ['-d']) - assert '' in result.output diff --git a/tests/unit/cli/test_plan.py b/tests/unit/cli/test_plan.py deleted file mode 100644 index 3ce3766e..00000000 --- a/tests/unit/cli/test_plan.py +++ /dev/null @@ -1,31 +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 -############################################################################## - -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 diff --git a/tests/unit/cli/test_qpi.py b/tests/unit/cli/test_qpi.py deleted file mode 100644 index 992c85d7..00000000 --- a/tests/unit/cli/test_qpi.py +++ /dev/null @@ -1,31 +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 -############################################################################## - -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, ['qpi', 'list']) - assert result.output == '' - - -def test_run(runner): - result = runner.invoke(cli, ['qpi', 'run', 'fake-qpi']) - assert result.output == '' - - result = runner.invoke(cli, ['qpi', 'run']) - assert 'Missing argument "name".' in result.output diff --git a/tests/unit/collector/transformer/__init__.py b/tests/unit/collector/transformer/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/unit/loader/__init__.py b/tests/unit/loader/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/unit/runner/__init__.py b/tests/unit/runner/__init__.py deleted file mode 100644 index e69de29b..00000000 -- cgit 1.2.3-korg