Files
python-barbicanclient/functionaltests/cli/base.py
Steve Heyman 8083923114 Initial setup for command line tests
Created a cli structure for testing command line client.

Part of this involved refactoring the base.py so that it could be
shared between client and command line tests.

Added basic help subcommand tests to show the flow between
behaviors and tests.

Change-Id: Ia3af13e90b3689c0c2ca5447ead0fb7fc33de086
2015-04-24 10:05:13 -05:00

47 lines
1.5 KiB
Python

"""
Copyright 2015 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import exceptions as exc
from functionaltests.base import BaseTestCase
from barbicanclient import barbican
class CmdLineTestCase(BaseTestCase):
def setUp(self):
self.LOG.info('Starting: %s', self._testMethodName)
super(CmdLineTestCase, self).setUp()
self.cmdline_client = barbican.Barbican()
def issue_barbican_command(self, argv):
""" Issue the barbican command and return its output.
:param argv: dict of keyword arguments to pass to the command. This
does NOT include "barbican" - that's not needed.
:return: list of strings returned by the command, one list element
per line of output. This means the caller doesn't have to worry about
parsing newlines, etc. If there is a problem then this method
will return None
"""
result = None
try:
self.cmdline_client.run(argv)
except exc.SystemExit:
result = self.cmdline_client.stdout.getvalue()
return result