blob: b846c46c3974f57169c0ae6a349c1e8f6931030b [file] [log] [blame]
Matthew Treinish9e26ca82016-02-23 11:43:20 -05001#
2# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
13
14
15from tempest.lib.cli import base as cli_base
16from tempest.lib import exceptions
Matthew Treinishffad78a2016-04-16 14:39:52 -040017from tempest.tests import base
Matthew Treinish9e26ca82016-02-23 11:43:20 -050018
19
20class TestExecute(base.TestCase):
21 def test_execute_success(self):
22 result = cli_base.execute("/bin/ls", action="tempest",
23 flags="-l -a")
24 self.assertIsInstance(result, str)
25 self.assertIn("__init__.py", result)
26
27 def test_execute_failure(self):
28 result = cli_base.execute("/bin/ls", action="tempest.lib",
29 flags="--foobar", merge_stderr=True,
30 fail_ok=True)
31 self.assertIsInstance(result, str)
32 self.assertIn("--foobar", result)
33
34 def test_execute_failure_raise_exception(self):
35 self.assertRaises(exceptions.CommandFailed, cli_base.execute,
36 "/bin/ls", action="tempest", flags="--foobar",
37 merge_stderr=True)