Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 1 | # |
| 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 | |
| 15 | from tempest.lib.cli import base as cli_base |
| 16 | from tempest.lib import exceptions |
Matthew Treinish | ffad78a | 2016-04-16 14:39:52 -0400 | [diff] [blame^] | 17 | from tempest.tests import base |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 18 | |
| 19 | |
| 20 | class 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) |