From fb6ca42fc0220264ef2e3cff3a35a8e48b1c04b5 Mon Sep 17 00:00:00 2001 From: Daryl Walleck Date: Sun, 14 Apr 2013 00:35:16 -0500 Subject: [PATCH] Add of flavor admin and keypair tests * Modifications to compute fixture to accomidate admin config * Added basic keypair test * Added basic add/delete flavor test Change-Id: I6a1feb1298f876568d1779c47a79644581f07d66 --- test_repo/compute/admin/test_flavors_admin.py | 33 +++++++++++++++++++ test_repo/compute/extensions/__init__.py | 15 +++++++++ .../compute/extensions/keypairs/__init__.py | 15 +++++++++ .../extensions/keypairs/test_keypairs.py | 33 +++++++++++++++++++ test_repo/compute/fixtures.py | 33 ++++++++----------- 5 files changed, 110 insertions(+), 19 deletions(-) create mode 100644 test_repo/compute/admin/test_flavors_admin.py create mode 100644 test_repo/compute/extensions/__init__.py create mode 100644 test_repo/compute/extensions/keypairs/__init__.py create mode 100644 test_repo/compute/extensions/keypairs/test_keypairs.py diff --git a/test_repo/compute/admin/test_flavors_admin.py b/test_repo/compute/admin/test_flavors_admin.py new file mode 100644 index 00000000..0f15be8a --- /dev/null +++ b/test_repo/compute/admin/test_flavors_admin.py @@ -0,0 +1,33 @@ +""" +Copyright 2013 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. +""" + +from cafe.drivers.unittest.decorators import tags +from test_repo.compute.fixtures import ComputeAdminFixture + +class FlavorsAdminTest(ComputeAdminFixture): + + @classmethod + def setUpClass(cls): + super(FlavorsAdminTest, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(FlavorsAdminTest, cls).tearDownClass() + + def test_create_delete_flavors(self): + self.admin_flavors_client.create_flavor(name='test2', ram='128', vcpus='1', + disk='10', id='99', is_public=True) + self.admin_flavors_client.delete_flavor('99') \ No newline at end of file diff --git a/test_repo/compute/extensions/__init__.py b/test_repo/compute/extensions/__init__.py new file mode 100644 index 00000000..59ab77fa --- /dev/null +++ b/test_repo/compute/extensions/__init__.py @@ -0,0 +1,15 @@ +""" +Copyright 2013 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. +""" diff --git a/test_repo/compute/extensions/keypairs/__init__.py b/test_repo/compute/extensions/keypairs/__init__.py new file mode 100644 index 00000000..59ab77fa --- /dev/null +++ b/test_repo/compute/extensions/keypairs/__init__.py @@ -0,0 +1,15 @@ +""" +Copyright 2013 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. +""" diff --git a/test_repo/compute/extensions/keypairs/test_keypairs.py b/test_repo/compute/extensions/keypairs/test_keypairs.py new file mode 100644 index 00000000..b6941acb --- /dev/null +++ b/test_repo/compute/extensions/keypairs/test_keypairs.py @@ -0,0 +1,33 @@ +""" +Copyright 2013 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. +""" + +from test_repo.compute.fixtures import ComputeFixture + +class FlavorsTest(ComputeFixture): + + def test_create_delete_keypair(self): + resp = self.keypairs_client.create_keypair('test3') + self.assertEqual(resp.status_code, 200) + + keypair = resp.entity + self.assertEqual(keypair.name, 'test3') + self.assertIsNotNone(keypair.public_key) + self.assertIsNotNone(keypair.fingerprint) + + self.keypairs_client.list_keypairs() + + self.keypairs_client.delete_keypair('test3') + diff --git a/test_repo/compute/fixtures.py b/test_repo/compute/fixtures.py index 9d4e1fd8..42544f1c 100644 --- a/test_repo/compute/fixtures.py +++ b/test_repo/compute/fixtures.py @@ -24,6 +24,7 @@ from cloudcafe.compute.common.exception_handler import ExceptionHandler from cloudcafe.compute.flavors_api.client import FlavorsClient from cloudcafe.compute.servers_api.client import ServersClient from cloudcafe.compute.images_api.client import ImagesClient +from cloudcafe.compute.extensions.keypairs_api.client import KeypairsClient from cloudcafe.compute.servers_api.behaviors import ServerBehaviors from cloudcafe.compute.images_api.behaviors import ImageBehaviors from cloudcafe.compute.config import ComputeConfig @@ -33,11 +34,9 @@ from cloudcafe.compute.servers_api.config import ServersConfig from cloudcafe.extensions.rax_auth.v2_0.tokens_api.client import TokenAPI_Client from cloudcafe.extensions.rax_auth.v2_0.tokens_api.behaviors import TokenAPI_Behaviors from cloudcafe.extensions.rax_auth.v2_0.tokens_api.config import TokenAPI_Config - from cloudcafe.identity.v2_0.tokens_api.client import TokenAPI_Client as OSTokenAPI_Client from cloudcafe.identity.v2_0.tokens_api.behaviors import TokenAPI_Behaviors as OSTokenAPI_Behaviors from cloudcafe.identity.v2_0.tokens_api.config import TokenAPI_Config as OSTokenAPI_Config - from cloudcafe.compute.config import ComputeAdminConfig @@ -78,6 +77,8 @@ class ComputeFixture(BaseTestFixture): 'json', 'json') cls.images_client = ImagesClient(url, access_data.token.id_, 'json', 'json') + #cls.keypairs_client = KeypairsClient(url, access_data.token.id_, + # 'json', 'json') cls.server_behaviors = ServerBehaviors(cls.servers_client, cls.servers_config, cls.images_config, @@ -207,25 +208,19 @@ class ComputeAdminFixture(BaseTestFixture): compute_service = access_data.get_service( cls.compute_config.compute_endpoint_name) url = compute_service.get_endpoint( - cls.compute_config.region).public_url - cls.flavors_client = FlavorsClient(url, access_data.token.id_, - 'json', 'json') - cls.servers_client = ServersClient(url, access_data.token.id_, - 'json', 'json') - cls.images_client = ImagesClient(url, access_data.token.id_, - 'json', 'json') - cls.server_behaviors = ServerBehaviors(cls.servers_client, - cls.servers_config, - cls.images_config, - cls.flavors_config) - cls.image_behaviors = ImageBehaviors(cls.images_client, - cls.images_config) - cls.flavors_client.add_exception_handler(ExceptionHandler()) - cls.resources = ResourcePool() - + compute_admin_config.region).public_url + cls.admin_flavors_client = FlavorsClient(url, access_data.token.id_, + 'json', 'json') + cls.admin_servers_client = ServersClient(url, access_data.token.id_, + 'json', 'json') + cls.admin_server_behaviors = ServerBehaviors(cls.admin_servers_client, + cls.servers_config, + cls.images_config, + cls.flavors_config) + cls.admin_servers_client.add_exception_handler(ExceptionHandler()) @classmethod def tearDownClass(cls): super(ComputeAdminFixture, cls).tearDownClass() cls.flavors_client.delete_exception_handler(ExceptionHandler()) - #cls.resources.release() \ No newline at end of file + cls.resources.release()