From 9936cdee1574e63ed8c712f5854e0a0c205ed4c1 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 28 Aug 2014 16:53:54 -0400 Subject: [PATCH] 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. --- requirements.txt | 1 + tempest_lib/cli/base.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4cc9d42..1329e07 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/tempest_lib/cli/base.py b/tempest_lib/cli/base.py index 7b9b3bf..1e32c06 100644 --- a/tempest_lib/cli/base.py +++ b/tempest_lib/cli/base.py @@ -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