diff options
| author | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-05-27 15:50:52 -0500 |
|---|---|---|
| committer | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-05-27 15:50:52 -0500 |
| commit | bc44cea775eb16d2ad2c7f46f0ddd418d3223584 (patch) | |
| tree | 4b3c49e50fc1e88f5de5f4c6db722b077bcf4113 | |
| parent | 1c8cea8858832584a1f7bfc7faf4259e190b9972 (diff) | |
| download | keystone-bc44cea775eb16d2ad2c7f46f0ddd418d3223584.tar.gz keystone-bc44cea775eb16d2ad2c7f46f0ddd418d3223584.tar.xz keystone-bc44cea775eb16d2ad2c7f46f0ddd418d3223584.zip | |
Build base classes for tests
| -rw-r--r-- | test/functional/base.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/functional/base.py b/test/functional/base.py index b1d59845..d30134bc 100644 --- a/test/functional/base.py +++ b/test/functional/base.py @@ -15,4 +15,63 @@ # limitations under the License. +import dtest + +import ksapi + + options = None + + +def _get_ksapi(): + """Get an instance of KeystoneAPI20.""" + + # If debug mode has been enabled, let's select a debug stream + dbstream = None + if options.debug: + dbstream = dtest.status + + # Build and return the API object + return ksapi.KeystoneAPI20(options.keystone, dbstream) + + +class BaseKeystoneTest(dtest.DTestCase): + """Base class for Keystone tests.""" + + def setUp(self): + """Initialize tests by setting up a KeystoneAPI20 to call.""" + + # Build the API object + self.ks = _get_ksapi() + + +class KeystoneTest(BaseKeystoneTest): + """Base class for Keystone tests.""" + + token = None + + @classmethod + def setUpClass(cls): + """Initialize tests by setting up a keystone token.""" + + # Get an API object + ks = _get_ksapi() + + # Next, let's authenticate + resp = ks.authenticate(options.username, options.password) + + # Finally, save the authentication token + cls.token = resp.obj['auth']['token']['id'] + + @classmethod + def tearDownClass(cls): + """Revoke the authentication token.""" + + # Get an API object + ks = _get_ksapi() + + # Now, let's revoke the token + resp = ks.revoke_token(cls.token, cls.token) + + # For completeness sake... + cls.token = None |
