diff options
author | Dan Smith <danms@us.ibm.com> | 2013-08-14 11:30:30 -0700 |
---|---|---|
committer | Dan Smith <danms@us.ibm.com> | 2013-08-23 07:25:17 -0700 |
commit | 28e937cd2bc19a4278c73ef7da0f71dfb3358fb8 (patch) | |
tree | 7c5d1dda6a9f7909b3103e2bf6388bf9801836bb /nova/tests/compute/test_keypairs.py | |
parent | e91c6ffbea7cdae3865b1f78f76c83cf1c5dc00e (diff) | |
download | nova-28e937cd2bc19a4278c73ef7da0f71dfb3358fb8.tar.gz |
Make compute_api use KeyPair objects
This makes compute_api's KeypairAPI use KeyPair objects to do
its work. Most of the change here is to tests to account for the
change.
Related to blueprint compute-api-objects
Change-Id: If516a88eac107670d9ae37fcfaf56f2add9dd0c5
Diffstat (limited to 'nova/tests/compute/test_keypairs.py')
-rw-r--r-- | nova/tests/compute/test_keypairs.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/nova/tests/compute/test_keypairs.py b/nova/tests/compute/test_keypairs.py index 147f636703..36ce74b522 100644 --- a/nova/tests/compute/test_keypairs.py +++ b/nova/tests/compute/test_keypairs.py @@ -25,7 +25,7 @@ from nova import exception from nova.openstack.common.gettextutils import _ from nova import quota from nova.tests.compute import test_compute - +from nova.tests.objects import test_keypair CONF = cfg.CONF QUOTAS = quota.QUOTAS @@ -51,21 +51,23 @@ class KeypairAPITestCase(test_compute.BaseTestCase): def _keypair_db_call_stubs(self): def db_key_pair_get_all_by_user(context, user_id): - return [{'name': self.existing_key_name, - 'public_key': self.pub_key, - 'fingerprint': self.fingerprint}] + return [dict(test_keypair.fake_keypair, + name=self.existing_key_name, + public_key=self.pub_key, + fingerprint=self.fingerprint)] def db_key_pair_create(context, keypair): - pass + return dict(test_keypair.fake_keypair, **keypair) def db_key_pair_destroy(context, user_id, name): pass def db_key_pair_get(context, user_id, name): if name == self.existing_key_name: - return {'name': self.existing_key_name, - 'public_key': self.pub_key, - 'fingerprint': self.fingerprint} + return dict(test_keypair.fake_keypair, + name=self.existing_key_name, + public_key=self.pub_key, + fingerprint=self.fingerprint) else: raise exception.KeypairNotFound(user_id=user_id, name=name) @@ -135,8 +137,8 @@ class CreateKeypairTestCase(KeypairAPITestCase, CreateImportSharedTestMixIn): func_name = 'create_key_pair' def test_success(self): - keypair = self.keypair_api.create_key_pair(self.ctxt, - self.ctxt.user_id, 'foo') + keypair, private_key = self.keypair_api.create_key_pair( + self.ctxt, self.ctxt.user_id, 'foo') self.assertEqual('foo', keypair['name']) |