diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/api/test_server.py (renamed from tests/unit/api/qtip_server_test.py) | 16 | ||||
-rw-r--r-- | tests/unit/cli/ansible_test.py | 31 | ||||
-rw-r--r-- | tests/unit/runner/perftest_test.py | 6 | ||||
-rw-r--r-- | tests/unit/runner/suite_test.py | 6 | ||||
-rw-r--r-- | tests/unit/runner/testplan_test.py | 6 |
5 files changed, 60 insertions, 5 deletions
diff --git a/tests/unit/api/qtip_server_test.py b/tests/unit/api/test_server.py index 96544c95..e9364d3d 100644 --- a/tests/unit/api/qtip_server_test.py +++ b/tests/unit/api/test_server.py @@ -1,9 +1,15 @@ -import qtip.api.qtip_server as server -import pytest import json -import mock import time +import mock +import pytest + +import qtip.api.cmd.server as server + + +def setup_module(): + server.add_routers() + @pytest.fixture def app(): @@ -66,7 +72,7 @@ class TestClass: 'state_detail': [{u'state': u'finished', u'benchmark': u'dhrystone_vm.yaml'}], 'result': 0}) ]) - @mock.patch('qtip.api.qtip_server.args_handler.prepare_and_run_benchmark') + @mock.patch('qtip.utils.args_handler.prepare_and_run_benchmark') def test_post_get_delete_job_successful(self, mock_args_handler, app_client, body, expected): mock_args_handler.return_value = {'result': 0, 'detail': {'host': [(u'10.20.6.14', {'unreachable': 0, @@ -107,7 +113,7 @@ class TestClass: ['job_id', 'It already has one job running now!']) ]) - @mock.patch('qtip.api.qtip_server.args_handler.prepare_and_run_benchmark', + @mock.patch('qtip.utils.args_handler.prepare_and_run_benchmark', side_effect=[side_effect_sleep(0.5), side_effect_pass]) def test_post_two_jobs_unsuccessful(self, mock_args_hanler, app_client, body, expected): reply_1 = app_client.post("/api/v1.0/jobs", data=body[0]) diff --git a/tests/unit/cli/ansible_test.py b/tests/unit/cli/ansible_test.py new file mode 100644 index 00000000..02941333 --- /dev/null +++ b/tests/unit/cli/ansible_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 + + +class TestClass(object): + + @pytest.fixture() + def runner(self): + return CliRunner() + + def test_prepare(self, runner): + result = runner.invoke(cli, ['ansible', 'prepare']) + assert result.output == "prepare ansible env\n" + + def test_show(self, runner): + result = runner.invoke(cli, ['ansible', 'show']) + assert result.output == "show ansible configuration\n" + + def test_status(self, runner): + result = runner.invoke(cli, ['ansible', 'status']) + assert result.output == "check connectivity\n" diff --git a/tests/unit/runner/perftest_test.py b/tests/unit/runner/perftest_test.py index 1f0b5631..2b400ac8 100644 --- a/tests/unit/runner/perftest_test.py +++ b/tests/unit/runner/perftest_test.py @@ -40,3 +40,9 @@ class TestPerfTest: assert Property.DESCRIPTION in desc assert Property.ABSPATH in desc assert Property.ABSPATH is not None + + def test_describe(self): + desc = PerfTest('test-a').describe() + assert Property.NAME in desc + assert Property.DESCRIPTION in desc + assert Property.ABSPATH in desc diff --git a/tests/unit/runner/suite_test.py b/tests/unit/runner/suite_test.py index 10205801..acfed82c 100644 --- a/tests/unit/runner/suite_test.py +++ b/tests/unit/runner/suite_test.py @@ -40,3 +40,9 @@ class TestSuite: assert Property.DESCRIPTION in suite_desc assert Property.ABSPATH in suite_desc assert Property.ABSPATH is not None + + def test_describe(self): + desc = Suite('suite-a').describe() + assert Property.NAME in desc + assert Property.DESCRIPTION in desc + assert Property.ABSPATH in desc diff --git a/tests/unit/runner/testplan_test.py b/tests/unit/runner/testplan_test.py index de8bf1e1..7e42f557 100644 --- a/tests/unit/runner/testplan_test.py +++ b/tests/unit/runner/testplan_test.py @@ -40,3 +40,9 @@ class TestTestPlan: assert Property.DESCRIPTION in desc assert Property.ABSPATH in desc assert Property.ABSPATH is not None + + def test_describe(self): + desc = TestPlan('plan-a').describe() + assert Property.NAME in desc + assert Property.DESCRIPTION in desc + assert Property.ABSPATH in desc |