Add a new base cli test class

This commit adds a new base test class for the cli testing framework.
This differs from the previous version in the tempest repo because it
uses an abstract method to initialize the client object. While in
tempest this was done inside the test class itself and leveraged the
config object.

Since the config object is being decoupled from the library defining
the test class this way allows any child test class to use whatever
credentials and previous config options directly in setup.
This commit is contained in:
Matthew Treinish 2014-08-28 16:53:54 -04:00
parent a745d09d03
commit 9936cdee15
2 changed files with 13 additions and 1 deletions

View File

@ -3,3 +3,4 @@ Babel>=1.3
fixtures>=0.3.14
oslo.config>=1.4.0.0a3
iso8601>=0.1.9
testresources>=0.2.4

View File

@ -20,6 +20,7 @@ import subprocess
import testtools
from tempest_lib import base
import tempest_lib.cli.output_parser
from tempest_lib import exceptions
from tempest_lib.openstack.common import log as logging
@ -92,7 +93,6 @@ class CLIClientBase(object):
def __init__(self, username='', password='', tenant_name='', uri='',
cli_dir='', *args, **kwargs):
super(CLIClientBase, self).__init__()
self.parser = tempest_lib.cli.output_parser
self.cli_dir = cli_dir if cli_dir else '/usr/bin'
self.username = username
self.tenant_name = tenant_name
@ -190,3 +190,14 @@ class CLIClientBase(object):
self.assertTrue(lines[0].startswith(beginning),
msg=('Beginning of first line has invalid content: %s'
% lines[:3]))
class ClientTestBase(base.BaseTestCase):
def setUp(self):
super(ClientTestBase, self).setUp()
self.clients = self._get_clients()
self.parser = tempest_lib.cli.output_parser
def _get_clients(self):
raise NotImplementedError