diff --git a/.gitignore b/.gitignore index ae11ae61..1a17daff 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,7 @@ pip-log.txt # vim *.swp + +#py.test logger +cc.master.log +metatests*.log diff --git a/cloudcafe/compute/extensions/security_groups_api/models/security_group_rule.py b/cloudcafe/compute/extensions/security_groups_api/models/security_group_rule.py index 3110476f..50c9295e 100644 --- a/cloudcafe/compute/extensions/security_groups_api/models/security_group_rule.py +++ b/cloudcafe/compute/extensions/security_groups_api/models/security_group_rule.py @@ -34,7 +34,7 @@ class IpRange(AutoMarshallingModel): @classmethod def _xml_ele_to_obj(cls, xml_ele): cidr = xml_ele.find('cidr').text - return IpRange(cidr) + return IpRange(cidr=cidr) class SecurityGroupRule(AutoMarshallingModel): diff --git a/cloudcafe/compute/quotas_api/models/quotas.py b/cloudcafe/compute/quotas_api/models/quotas.py index 045c2f53..ccd6a7b9 100644 --- a/cloudcafe/compute/quotas_api/models/quotas.py +++ b/cloudcafe/compute/quotas_api/models/quotas.py @@ -54,7 +54,7 @@ class Quota(AutoMarshallingModel): quota_dict.get('metadata_items'), quota_dict.get('ram'), quota_dict.get('security_group_rules'), - quota_dict.get('security_group_rules')) + quota_dict.get('security_groups')) @classmethod def _json_to_obj(cls, serialized_str): diff --git a/cloudcafe/compute/tests/integration/hosts/responses.py b/cloudcafe/compute/tests/integration/hosts/responses.py deleted file mode 100644 index 599ffe20..00000000 --- a/cloudcafe/compute/tests/integration/hosts/responses.py +++ /dev/null @@ -1,79 +0,0 @@ -""" -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. -""" - - -class HostsMockResponse(): - - def __init__(self, format): - self.format = format - - def list_hosts(self): - return getattr(self, '_{0}_hosts'.format(self.format))() - - def get_host(self): - return getattr(self, '_{0}_host'.format(self.format))() - - def _json_hosts(self): - return '{"hosts":[{' \ - '"host_name": "787f4f6dda1b409bb8b2f9082349690e",' \ - '"service": "compute",' \ - '"zone": "nova"},' \ - '"{host_name": "a98b433151084aee8b1a986e28823b36",' \ - '"service": "cert",' \ - '"zone": "internal"}]}' - - def _xml_hosts(self): - return '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' - - def _xml_host(self): - return '' \ - '' \ - '' \ - '(total)' \ - '8192' \ - 'ecf3458ac6bf4a299cc2e0efa740f426' \ - '1' \ - '1028' \ - '' \ - '' - - def _json_host(cls): - return '{"host":' \ - ' [{"resource":' \ - ' {"cpu": 1,' \ - '"disk_gb": 1028,' \ - '"host": "787f4f6dda1b409bb8b2f9082349690e",' \ - '"memory_mb": 8192,"project": "(total)"}},' \ - '{"resource":' \ - ' {"cpu": 0,' \ - '"disk_gb": 0,' \ - '"host": "787f4f6dda1b409bb8b2f9082349690e",' \ - '"memory_mb": 512,' \ - '"project": "(used_now)"}}]}' diff --git a/cloudcafe/compute/tests/integration/security_group_rules/responses.py b/cloudcafe/compute/tests/integration/security_group_rules/responses.py deleted file mode 100644 index b4323db2..00000000 --- a/cloudcafe/compute/tests/integration/security_group_rules/responses.py +++ /dev/null @@ -1,50 +0,0 @@ -""" -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. -""" - - -class SecurityGroupRulesMockResponse(): - - def __init__(self, format): - self.format = format - - def _get_sec_group_rule(self): - return getattr(self, '_{0}_sec_group_rule'.format(self.format))() - - def _json_sec_group_rule(self): - return '{"security_group_rule":' \ - ' {"from_port": 80,' \ - ' "ip_protocol": "tcp",' \ - ' "to_port": 8080,' \ - ' "parent_group_id": 2,' \ - ' "ip_range": {"cidr": "0.0.0.0/0"},' \ - ' "id": 1' \ - ' "group": {}}}' - - def _xml_sec_group_rule(self): - return '' \ - '' \ - '80' \ - 'tcp' \ - '8080' \ - '' \ - '0.0.0.0/0' \ - '' \ - '' \ - 'None' \ - 'None' \ - '' \ - '' diff --git a/cloudcafe/compute/tests/unit/hypervisors/test_hypervisors.py b/cloudcafe/compute/tests/unit/hypervisors/test_hypervisors.py deleted file mode 100644 index bd7fba78..00000000 --- a/cloudcafe/compute/tests/unit/hypervisors/test_hypervisors.py +++ /dev/null @@ -1,106 +0,0 @@ -""" -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. -""" - -import unittest2 as unittest -from cloudcafe.compute.hypervisors_api.model.hypervisors import Hypervisor - - -class HypervisorDomainTest(object): - - def test_hypervisor_attr(self): - self.assertEqual(self.hypervisor[0].id, "1") - self.assertEqual(self.hypervisor[0].hypervisor_hostname, - "hypervisor_test") - - -class HypervisorDomainJSONTest(unittest.TestCase, HypervisorDomainTest): - - @classmethod - def setUp(cls): - cls.hypervisor_json = '{"hypervisors": [{' \ - '"id": "1", ' \ - '"hypervisor_hostname": "hypervisor_test"}]}' - cls.hypervisor = Hypervisor.deserialize(cls.hypervisor_json, "json") - - -class HypervisorDomainXMLTest(unittest.TestCase, HypervisorDomainTest): - - @classmethod - def setUp(cls): - cls.hypervisor_xml = '' \ - '' \ - '' - cls.hypervisor = Hypervisor.deserialize(cls.hypervisor_xml, "xml") - - -class HypervisorServerCollectionDomainTest(object): - - def test_hypervisor_servers_length(self): - self.assertEqual(len(self.hypervisor.servers), 2) - - def test_hypervisor_servers_attr(self): - self.assertTrue("server_one" in - [server.name for server in self.hypervisor.servers]) - self.assertTrue("server_two" in - [server.name for server in self.hypervisor.servers]) - self.assertTrue("b1ea4f1b-201c-47c5-95b9-c6fe2df39af0" - in [server.id - for server in self.hypervisor.servers]) - self.assertTrue("9327b134-b1f5-43ec-a8f1-2b6eb153c739" - in [server.id - for server in self.hypervisor.servers]) - - -class ServersDomainCollectionJSONTest(unittest.TestCase, - HypervisorServerCollectionDomainTest): - - @classmethod - def setUp(cls): - cls.hypervisor_json = '{"hypervisors": [{' \ - '"id": 1, ' \ - '"hypervisor_hostname": "hypervisor_test", ' \ - '"servers": [{' \ - '"uuid": ' \ - '"b1ea4f1b-201c-47c5-95b9-c6fe2df39af0", ' \ - '"name": "server_one"}, ' \ - '{"uuid": ' \ - '"9327b134-b1f5-43ec-a8f1-2b6eb153c739", ' \ - '"name": "server_two"}]}]}' - cls.hypervisor = Hypervisor.deserialize(cls.hypervisor_json, "json") - - -class ServersDomainCollectionXMLTest(unittest.TestCase, - HypervisorServerCollectionDomainTest): - - @classmethod - def setUp(cls): - cls.hypervisor_xml = '' \ - '' \ - '' \ - '' \ - '' \ - '' \ - '' - cls.hypervisor = Hypervisor.deserialize(cls.hypervisor_xml, - "xml") - -if __name__ == '__main__': - unittest.main() diff --git a/cloudcafe/compute/tests/unit/security_group_rules/test_security_group_rule.py b/cloudcafe/compute/tests/unit/security_group_rules/test_security_group_rule.py deleted file mode 100644 index ce0ac57a..00000000 --- a/cloudcafe/compute/tests/unit/security_group_rules/test_security_group_rule.py +++ /dev/null @@ -1,84 +0,0 @@ -""" -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. -""" - -import unittest2 as unittest - -from cloudcafe.compute.extensions.security_groups_api.models.\ - security_group_rule import SecurityGroupRule - - -class SecurityGroupRuleDomainTest(object): - - def test_security_group_rule_attributes(self): - self.assertEqual(str(self.sec_group_rule.from_port), '80') - self.assertEqual(str(self.sec_group_rule.to_port), '8080') - self.assertEqual(self.sec_group_rule.ip_protocol, 'tcp') - self.assertEqual(self.sec_group_rule.id, - 'bf57c853-cdf2-4c99-9f9a-79b3e9dc13a8') - self.assertEqual(self.sec_group_rule.parent_group_id, - 'b32c047d-5efc-42ab-8476-3ac9f3681af2') - self.assertEqual(self.sec_group_rule.ip_range.cidr, '0.0.0.0/0') - - -class SecurityGroupRuleDomainJSONTest(unittest.TestCase, - SecurityGroupRuleDomainTest): - - @classmethod - def setUpClass(cls): - cls.sec_group_rule_json = '{"security_group_rule":' \ - ' {"from_port": 80,' \ - '"group": {},' \ - '"ip_protocol": "tcp",' \ - '"to_port": 8080,' \ - '"parent_group_id":' \ - ' "b32c047d-5efc-42ab-8476-3ac9f3681af2",' \ - '"ip_range": {"cidr": "0.0.0.0/0"},' \ - '"id":' \ - ' "bf57c853-cdf2-4c99-9f9a-79b3e9dc13a8"}}' - cls.sec_group_rule = SecurityGroupRule.\ - deserialize(cls.sec_group_rule_json, "json") - - -class SecurityGroupRuleDomainXMLTest(unittest.TestCase, - SecurityGroupRuleDomainTest): - - @classmethod - def setUpClass(cls): - cls.sec_group_rule_xml = '' \ - '' \ - 'tcp' \ - '80' \ - '8080' \ - '' \ - 'None' \ - 'None' \ - '' \ - '' \ - '0.0.0.0/0' \ - '' \ - '' - cls.sec_group_rule = SecurityGroupRule.\ - deserialize(cls.sec_group_rule_xml, "xml") - -if __name__ == '__main__': - unittest.main() diff --git a/cloudcafe/compute/tests/__init__.py b/metatests/cloudcafe/__init__.py similarity index 100% rename from cloudcafe/compute/tests/__init__.py rename to metatests/cloudcafe/__init__.py diff --git a/cloudcafe/compute/tests/integration/__init__.py b/metatests/cloudcafe/compute/__init__.py similarity index 100% rename from cloudcafe/compute/tests/integration/__init__.py rename to metatests/cloudcafe/compute/__init__.py diff --git a/cloudcafe/compute/tests/integration/fixtures.py b/metatests/cloudcafe/compute/fixtures.py similarity index 72% rename from cloudcafe/compute/tests/integration/fixtures.py rename to metatests/cloudcafe/compute/fixtures.py index 6bdfb794..361a60ca 100644 --- a/cloudcafe/compute/tests/integration/fixtures.py +++ b/metatests/cloudcafe/compute/fixtures.py @@ -14,12 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. """ +import unittest2 as unittest from httpretty import HTTPretty -from cafe.drivers.unittest.fixtures import BaseTestFixture - -class IntegrationTestFixture(BaseTestFixture): +class ClientTestFixture(unittest.TestCase): AUTH_TOKEN = 'dda0e9d0a1084f67bb9ea4e91abcd4ec' COMPUTE_API_ENDPOINT = 'http://localhost:5000/v1' @@ -29,16 +28,16 @@ class IntegrationTestFixture(BaseTestFixture): CONTENT_TYPE = 'application/{0}'.format(FORMAT) ACCEPT = 'application/{0}'.format(FORMAT) + @classmethod def setUp(cls): - super(IntegrationTestFixture, cls).setUp() HTTPretty.reset() HTTPretty.enable() + @classmethod def tearDown(cls): - super(IntegrationTestFixture, cls).tearDown() HTTPretty.disable() def _assert_default_headers_in_request(self, request): - self.assertEqual(request.headers['X-Auth-Token'], self.AUTH_TOKEN) - self.assertEqual(request.headers['Content-Type'], self.CONTENT_TYPE) - self.assertEqual(request.headers['Accept'], self.ACCEPT) + assert request.headers['X-Auth-Token'] == self.AUTH_TOKEN + assert request.headers['Content-Type'] == self.CONTENT_TYPE + assert request.headers['Accept'] == self.ACCEPT diff --git a/cloudcafe/compute/tests/integration/hosts/__init__.py b/metatests/cloudcafe/compute/hosts/__init__.py similarity index 100% rename from cloudcafe/compute/tests/integration/hosts/__init__.py rename to metatests/cloudcafe/compute/hosts/__init__.py diff --git a/cloudcafe/compute/tests/integration/hypervisors/__init__.py b/metatests/cloudcafe/compute/hosts/client/__init__.py similarity index 100% rename from cloudcafe/compute/tests/integration/hypervisors/__init__.py rename to metatests/cloudcafe/compute/hosts/client/__init__.py diff --git a/metatests/cloudcafe/compute/hosts/client/responses.py b/metatests/cloudcafe/compute/hosts/client/responses.py new file mode 100644 index 00000000..4829a9c9 --- /dev/null +++ b/metatests/cloudcafe/compute/hosts/client/responses.py @@ -0,0 +1,79 @@ +""" +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. +""" + + +class HostsMockResponse(): + + def __init__(self, format): + self.format = format + + def list_hosts(self): + return getattr(self, '_{0}_hosts'.format(self.format))() + + def get_host(self): + return getattr(self, '_{0}_host'.format(self.format))() + + def _json_hosts(self): + return ('{"hosts":[{' + '"host_name": "787f4f6dda1b409bb8b2f9082349690e",' + '"service": "compute",' + '"zone": "nova"},' + '"{host_name": "a98b433151084aee8b1a986e28823b36",' + '"service": "cert",' + '"zone": "internal"}]}') + + def _xml_hosts(self): + return ('' + '' + '' + '' + '' + '' + '' + '' + '') + + def _xml_host(self): + return ('' + '' + '' + '(total)' + '8192' + 'ecf3458ac6bf4a299cc2e0efa740f426' + '1' + '1028' + '' + '') + + def _json_host(cls): + return ('{"host":' + ' [{"resource":' + ' {"cpu": 1,' + '"disk_gb": 1028,' + '"host": "787f4f6dda1b409bb8b2f9082349690e",' + '"memory_mb": 8192,"project": "(total)"}},' + '{"resource":' + ' {"cpu": 0,' + '"disk_gb": 0,' + '"host": "787f4f6dda1b409bb8b2f9082349690e",' + '"memory_mb": 512,' + '"project": "(used_now)"}}]}') diff --git a/cloudcafe/compute/tests/integration/hosts/test_hosts_client.py b/metatests/cloudcafe/compute/hosts/client/test_hosts_client.py similarity index 76% rename from cloudcafe/compute/tests/integration/hosts/test_hosts_client.py rename to metatests/cloudcafe/compute/hosts/client/test_hosts_client.py index 5146948e..8aa86274 100644 --- a/cloudcafe/compute/tests/integration/hosts/test_hosts_client.py +++ b/metatests/cloudcafe/compute/hosts/client/test_hosts_client.py @@ -14,19 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. """ -import unittest2 as unittest -import httpretty +from httpretty import HTTPretty from cloudcafe.compute.hosts_api.client import HostsClient -from cloudcafe.compute.tests.integration.fixtures import IntegrationTestFixture -from cloudcafe.compute.tests.integration.hosts.responses\ +from metatests.cloudcafe.compute.fixtures import ClientTestFixture +from metatests.cloudcafe.compute.hosts.client.responses \ import HostsMockResponse HOST_NAME = "787f4f6dda1b409bb8b2f9082349690e" -class HostsClientTest(IntegrationTestFixture): +class HostsClientTest(ClientTestFixture): @classmethod def setUpClass(cls): @@ -42,20 +41,15 @@ class HostsClientTest(IntegrationTestFixture): cls.mock_response = HostsMockResponse(cls.FORMAT) def test_list_hosts(self): - httpretty.register_uri(httpretty.GET, self.hosts_uri, + HTTPretty.register_uri(HTTPretty.GET, self.hosts_uri, body=self.mock_response.list_hosts()) response = self.hosts_client.list_hosts() self.assertEqual(200, response.status_code) - self.assertEqual(self.mock_response.list_hosts(), - response.content) + self.assertEqual(self.mock_response.list_hosts(), response.content) def test_get_host(self): - httpretty.register_uri(httpretty.GET, self.host_uri, + HTTPretty.register_uri(HTTPretty.GET, self.host_uri, body=self.mock_response.get_host()) response = self.hosts_client.get_host(HOST_NAME) self.assertEqual(200, response.status_code) self.assertEqual(self.mock_response.get_host(), response.content) - - -if __name__ == '__main__': - unittest.main() diff --git a/cloudcafe/compute/tests/integration/quotas/__init__.py b/metatests/cloudcafe/compute/hosts/models/__init__.py similarity index 100% rename from cloudcafe/compute/tests/integration/quotas/__init__.py rename to metatests/cloudcafe/compute/hosts/models/__init__.py diff --git a/cloudcafe/compute/tests/unit/hosts/test_hosts.py b/metatests/cloudcafe/compute/hosts/models/test_hosts.py similarity index 54% rename from cloudcafe/compute/tests/unit/hosts/test_hosts.py rename to metatests/cloudcafe/compute/hosts/models/test_hosts.py index 9acc1330..ba5ddab5 100644 --- a/cloudcafe/compute/tests/unit/hosts/test_hosts.py +++ b/metatests/cloudcafe/compute/hosts/models/test_hosts.py @@ -44,12 +44,12 @@ class HostDomainJSONTest(unittest.TestCase, HostDomainTest): @classmethod def setUpClass(cls): - cls.host_json = '{"host":[{"resource":' \ - '{"cpu": "1",' \ - '"disk_gb": "1028", ' \ - ' "host": "nova", ' \ - '"memory_mb": "8192", ' \ - '"project": "(total)"}}]}' + cls.host_json = ('{"host":[{"resource":' + '{"cpu": "1",' + '"disk_gb": "1028", ' + ' "host": "nova", ' + '"memory_mb": "8192", ' + '"project": "(total)"}}]}') cls.host = Host.deserialize(cls.host_json, "json") @@ -57,13 +57,13 @@ class HostDomainXMLTest(unittest.TestCase, HostDomainTest): @classmethod def setUpClass(cls): - cls.host_xml = '' \ - ' ' \ - ' (total)' \ - ' 8192' \ - ' nova 1' \ - ' 1028' \ - ' ' + cls.host_xml = ('' + ' ' + ' (total)' + ' 8192' + ' nova 1' + ' 1028' + ' ') cls.host = Host.deserialize(cls.host_xml, "xml") @@ -71,19 +71,19 @@ class HostDomainXMLTest(unittest.TestCase, HostDomainTest): class HostDomainCollectionTest(object): def test_hosts_length(self): - self.assertEqual(len(self.hosts), 2) + assert len(self.hosts) == 2 def test_host_names(self): - self.assertEqual(self.hosts[0].host_name, "host_name1") - self.assertEqual(self.hosts[1].host_name, "host_name2") + assert self.hosts[0].host_name == "host_name1" + assert self.hosts[1].host_name == "host_name2" def test_host_services(self): - self.assertEqual(self.hosts[0].service, "compute1") - self.assertEqual(self.hosts[1].service, "compute2") + assert self.hosts[0].service == "compute1" + assert self.hosts[1].service == "compute2" def test_host_zones(self): - self.assertEqual(self.hosts[0].zone, "nova1") - self.assertEqual(self.hosts[1].zone, "nova2") + assert self.hosts[0].zone == "nova1" + assert self.hosts[1].zone == "nova2" class HostDomainCollectionJSONTest(unittest.TestCase, @@ -91,12 +91,12 @@ class HostDomainCollectionJSONTest(unittest.TestCase, @classmethod def setUpClass(cls): - cls.hosts_json = '{"hosts":' \ - '[{"host_name":' \ - ' "host_name1","service": "compute1",' \ - '"zone": "nova1"},' \ - '{"host_name": "host_name2",' \ - '"service": "compute2","zone": "nova2"}]}' + cls.hosts_json = ('{"hosts":' + '[{"host_name":' + ' "host_name1","service": "compute1",' + '"zone": "nova1"},' + '{"host_name": "host_name2",' + '"service": "compute2","zone": "nova2"}]}') cls.hosts = Host.deserialize(cls.hosts_json, "json") @@ -104,15 +104,11 @@ class HostDomainCollectionXMLTest(unittest.TestCase, HostDomainCollectionTest): @classmethod def setUpClass(cls): - cls.hosts_xml = '' \ - '' \ - '' \ - '' \ - '' + cls.hosts_xml = ('' + '' + '' + '' + '') cls.hosts = Host.deserialize(cls.hosts_xml, "xml") - - -if __name__ == '__main__': - unittest.main() diff --git a/cloudcafe/compute/tests/integration/security_group_rules/__init__.py b/metatests/cloudcafe/compute/hypervisors/__init__.py similarity index 100% rename from cloudcafe/compute/tests/integration/security_group_rules/__init__.py rename to metatests/cloudcafe/compute/hypervisors/__init__.py diff --git a/cloudcafe/compute/tests/unit/__init__.py b/metatests/cloudcafe/compute/hypervisors/client/__init__.py similarity index 100% rename from cloudcafe/compute/tests/unit/__init__.py rename to metatests/cloudcafe/compute/hypervisors/client/__init__.py diff --git a/cloudcafe/compute/tests/integration/hypervisors/responses.py b/metatests/cloudcafe/compute/hypervisors/client/responses.py similarity index 56% rename from cloudcafe/compute/tests/integration/hypervisors/responses.py rename to metatests/cloudcafe/compute/hypervisors/client/responses.py index 6c47bbc8..d52980e8 100644 --- a/cloudcafe/compute/tests/integration/hypervisors/responses.py +++ b/metatests/cloudcafe/compute/hypervisors/client/responses.py @@ -19,18 +19,18 @@ class HypervisorsClientMockResponse(object): @classmethod def list_hypervisors(cls): - return '{"hypervisors": [{' \ - '"id": 1, ' \ - '"hypervisor_hostname": "hypervisor_test"}' \ - ']}' + return ('{"hypervisors": [{' + '"id": 1, ' + '"hypervisor_hostname": "hypervisor_test"}' + ']}') @classmethod def list_hypervisor_servers(cls): - return '{"hypervisors": [{ '\ - '"id": 1,' \ - '"hypervisor_hostname": "hypervisor_test",' \ - '"servers":' \ - '[{"uuid": "b1ea4f1b-201c-47c5-95b9-c6fe2df39af0",' \ - '"name": "instance-00000003"},' \ - '{"uuid": "9327b134-b1f5-43ec-a8f1-2b6eb153c739",' \ - '"name": "instance-00000005"}}]}]}' + return ('{"hypervisors": [{ ' + '"id": 1,' + '"hypervisor_hostname": "hypervisor_test",' + '"servers":' + '[{"uuid": "b1ea4f1b-201c-47c5-95b9-c6fe2df39af0",' + '"name": "instance-00000003"},' + '{"uuid": "9327b134-b1f5-43ec-a8f1-2b6eb153c739",' + '"name": "instance-00000005"}}]}]}') diff --git a/cloudcafe/compute/tests/integration/hypervisors/test_hypervisor_client.py b/metatests/cloudcafe/compute/hypervisors/client/test_hypervisor_client.py similarity index 74% rename from cloudcafe/compute/tests/integration/hypervisors/test_hypervisor_client.py rename to metatests/cloudcafe/compute/hypervisors/client/test_hypervisor_client.py index af9cebce..b16f0051 100644 --- a/cloudcafe/compute/tests/integration/hypervisors/test_hypervisor_client.py +++ b/metatests/cloudcafe/compute/hypervisors/client/test_hypervisor_client.py @@ -14,18 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. """ -import unittest2 as unittest -import httpretty +from httpretty import HTTPretty from cloudcafe.compute.hypervisors_api.client import HypervisorsClient -from cloudcafe.compute.tests.integration.fixtures import IntegrationTestFixture -from cloudcafe.compute.tests.integration.hypervisors.responses \ +from metatests.cloudcafe.compute.fixtures import ClientTestFixture +from metatests.cloudcafe.compute.hypervisors.client.responses \ import HypervisorsClientMockResponse HYPERVISOR_HOSTNAME = "hypervisor_test" -class HypervisorsClientTest(IntegrationTestFixture): +class HypervisorsClientTest(ClientTestFixture): @classmethod def setUpClass(cls): @@ -42,31 +41,24 @@ class HypervisorsClientTest(IntegrationTestFixture): HYPERVISOR_HOSTNAME) cls.mock_response = HypervisorsClientMockResponse() - @httpretty.activate def test_list_hypervisors(self): - httpretty.register_uri(httpretty.GET, self.hypervisors_uri, + HTTPretty.register_uri(HTTPretty.GET, self.hypervisors_uri, body=self.mock_response. list_hypervisors()) response = self.hypervisor_client.list_hypervisors() self.assertEqual(200, response.status_code) - self._assert_default_headers_in_request() + self._assert_default_headers_in_request(HTTPretty.last_request) self.assertEqual(HypervisorsClientMockResponse.list_hypervisors(), response.content) - @httpretty.activate def test_list_hypervisor_servers(self): - httpretty.register_uri(httpretty.GET, self.hypervisor_servers_uri, + HTTPretty.register_uri(HTTPretty.GET, self.hypervisor_servers_uri, body=self.mock_response. list_hypervisor_servers()) response = self.hypervisor_client.\ list_hypervisor_servers(HYPERVISOR_HOSTNAME) self.assertEqual(200, response.status_code) - self._assert_default_headers_in_request() - self.assertEqual(HypervisorsClientMockResponse. - list_hypervisor_servers(), - response.content) - - -if __name__ == '__main__': - unittest.main() - + self._assert_default_headers_in_request(HTTPretty.last_request) + self.assertEqual( + HypervisorsClientMockResponse.list_hypervisor_servers(), + response.content) diff --git a/cloudcafe/compute/tests/unit/hosts/__init__.py b/metatests/cloudcafe/compute/hypervisors/models/__init__.py similarity index 100% rename from cloudcafe/compute/tests/unit/hosts/__init__.py rename to metatests/cloudcafe/compute/hypervisors/models/__init__.py diff --git a/metatests/cloudcafe/compute/hypervisors/models/test_hypervisors.py b/metatests/cloudcafe/compute/hypervisors/models/test_hypervisors.py new file mode 100644 index 00000000..261a7734 --- /dev/null +++ b/metatests/cloudcafe/compute/hypervisors/models/test_hypervisors.py @@ -0,0 +1,105 @@ +""" +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. +""" + +import unittest2 as unittest +from cloudcafe.compute.hypervisors_api.model.hypervisors import Hypervisor + + +class HypervisorDomainTest(object): + + def test_hypervisor_attr(self): + self.assertEqual(self.hypervisor[0].id, "1") + self.assertEqual(self.hypervisor[0].hypervisor_hostname, + "hypervisor_test") + + +class HypervisorDomainJSONTest(unittest.TestCase, HypervisorDomainTest): + + @classmethod + def setUp(cls): + cls.hypervisor_json = ('{"hypervisors": [{' + '"id": "1", ' + '"hypervisor_hostname": "hypervisor_test"}]}') + cls.hypervisor = Hypervisor.deserialize(cls.hypervisor_json, "json") + + +class HypervisorDomainXMLTest(unittest.TestCase, HypervisorDomainTest): + + @classmethod + def setUp(cls): + cls.hypervisor_xml = ('' + '' + '') + cls.hypervisor = Hypervisor.deserialize(cls.hypervisor_xml, "xml") + + +class HypervisorServerCollectionDomainTest(object): + + def test_hypervisor_servers_length(self): + self.assertEqual(len(self.hypervisor.servers), 2) + + def test_hypervisor_servers_attr(self): + self.assertTrue( + "server_one" in + [server.name for server in self.hypervisor.servers]) + self.assertTrue( + "server_two" in + [server.name for server in self.hypervisor.servers]) + self.assertTrue( + "b1ea4f1b-201c-47c5-95b9-c6fe2df39af0" in + [server.id for server in self.hypervisor.servers]) + self.assertTrue( + "9327b134-b1f5-43ec-a8f1-2b6eb153c739" in + [server.id for server in self.hypervisor.servers]) + + +class ServersDomainCollectionJSONTest(unittest.TestCase, + HypervisorServerCollectionDomainTest): + + @classmethod + def setUp(cls): + cls.hypervisor_json = ('{"hypervisors": [{' + '"id": 1, ' + '"hypervisor_hostname": "hypervisor_test", ' + '"servers": [{' + '"uuid": ' + '"b1ea4f1b-201c-47c5-95b9-c6fe2df39af0", ' + '"name": "server_one"}, ' + '{"uuid": ' + '"9327b134-b1f5-43ec-a8f1-2b6eb153c739", ' + '"name": "server_two"}]}]}') + cls.hypervisor = Hypervisor.deserialize(cls.hypervisor_json, "json") + + +class ServersDomainCollectionXMLTest(unittest.TestCase, + HypervisorServerCollectionDomainTest): + + @classmethod + def setUp(cls): + cls.hypervisor_xml = ('' + '' + '' + '' + '' + '' + '') + cls.hypervisor = Hypervisor.deserialize(cls.hypervisor_xml, + "xml") diff --git a/cloudcafe/compute/tests/unit/hypervisors/__init__.py b/metatests/cloudcafe/compute/quotas/__init__.py similarity index 100% rename from cloudcafe/compute/tests/unit/hypervisors/__init__.py rename to metatests/cloudcafe/compute/quotas/__init__.py diff --git a/cloudcafe/compute/tests/unit/quotas/__init__.py b/metatests/cloudcafe/compute/quotas/client/__init__.py similarity index 100% rename from cloudcafe/compute/tests/unit/quotas/__init__.py rename to metatests/cloudcafe/compute/quotas/client/__init__.py diff --git a/cloudcafe/compute/tests/integration/quotas/responses.py b/metatests/cloudcafe/compute/quotas/client/responses.py similarity index 100% rename from cloudcafe/compute/tests/integration/quotas/responses.py rename to metatests/cloudcafe/compute/quotas/client/responses.py diff --git a/cloudcafe/compute/tests/integration/quotas/test_quotas_client.py b/metatests/cloudcafe/compute/quotas/client/test_quotas_client.py similarity index 77% rename from cloudcafe/compute/tests/integration/quotas/test_quotas_client.py rename to metatests/cloudcafe/compute/quotas/client/test_quotas_client.py index 0348d417..16f68a38 100644 --- a/cloudcafe/compute/tests/integration/quotas/test_quotas_client.py +++ b/metatests/cloudcafe/compute/quotas/client/test_quotas_client.py @@ -14,16 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. """ -import unittest2 as unittest from httpretty import HTTPretty from cloudcafe.compute.quotas_api.client import QuotasClient -from cloudcafe.compute.tests.integration.fixtures import IntegrationTestFixture -from cloudcafe.compute.tests.integration.quotas.responses\ +from metatests.cloudcafe.compute.fixtures import ClientTestFixture +from metatests.cloudcafe.compute.quotas.client.responses \ import QuotasMockResponse -class QuotasClientTest(IntegrationTestFixture): +class QuotasClientTest(ClientTestFixture): @classmethod def setUpClass(cls): @@ -33,10 +32,11 @@ class QuotasClientTest(IntegrationTestFixture): auth_token=cls.AUTH_TOKEN, serialize_format=cls.FORMAT, deserialize_format=cls.FORMAT) - cls.quotas_uri = "{0}/os-quota-sets/{1}".\ - format(cls.COMPUTE_API_ENDPOINT, cls.TENANT_ID) - cls.default_quotas_uri = "{0}/os-quota-sets/{1}/defaults".\ - format(cls.COMPUTE_API_ENDPOINT, cls.TENANT_ID) + cls.quotas_uri = ("{0}/os-quota-sets/{1}". + format(cls.COMPUTE_API_ENDPOINT, cls.TENANT_ID)) + cls.default_quotas_uri = ("{0}/os-quota-sets/{1}/defaults". + format(cls.COMPUTE_API_ENDPOINT, + cls.TENANT_ID)) cls.mock_response = QuotasMockResponse(cls.FORMAT) def test_get_quota(self): @@ -62,14 +62,13 @@ class QuotasClientTest(IntegrationTestFixture): def test_update_quota(self): HTTPretty.register_uri(HTTPretty.PUT, self.quotas_uri, body=self.mock_response._get_quota()) - actual_response = self.quotas_client.\ - update_quota(self.TENANT_ID, security_groups=45) + actual_response = (self.quotas_client. + update_quota(self.TENANT_ID, security_groups=45)) - expected_request_body = '{"quota_set": {"security_group_rules": 45}}' + expected_request_body = '{"quota_set": {"security_groups": 45}}' self._assert_default_headers_in_request(HTTPretty.last_request) self.assertEqual(200, actual_response.status_code) - self.assertEqual(HTTPretty.last_request.body, - expected_request_body) + self.assertEqual(HTTPretty.last_request.body, expected_request_body) self.assertEqual(self.mock_response._get_quota(), actual_response.content) @@ -78,7 +77,3 @@ class QuotasClientTest(IntegrationTestFixture): actual_response = self.quotas_client.delete_quota(self.TENANT_ID) self.assertEqual(202, actual_response.status_code) - - -if __name__ == '__main__': - unittest.main() diff --git a/cloudcafe/compute/tests/unit/security_group_rules/__init__.py b/metatests/cloudcafe/compute/quotas/models/__init__.py similarity index 100% rename from cloudcafe/compute/tests/unit/security_group_rules/__init__.py rename to metatests/cloudcafe/compute/quotas/models/__init__.py diff --git a/cloudcafe/compute/tests/unit/quotas/test_quota_requests.py b/metatests/cloudcafe/compute/quotas/models/test_quota_requests.py similarity index 77% rename from cloudcafe/compute/tests/unit/quotas/test_quota_requests.py rename to metatests/cloudcafe/compute/quotas/models/test_quota_requests.py index c24790a7..5c649141 100644 --- a/cloudcafe/compute/tests/unit/quotas/test_quota_requests.py +++ b/metatests/cloudcafe/compute/quotas/models/test_quota_requests.py @@ -24,17 +24,14 @@ class QuotaRequestsTest(unittest.TestCase): def test_serialize_host_update_request_to_json(self): quota_obj = UpdateQuotaRequest(security_groups=45) json_serialized_quota = quota_obj.serialize("json") - expected_json = '{"quota_set": {"security_group_rules": 45}}' + expected_json = '{"quota_set": {"security_groups": 45}}' self.assertEqual(json_serialized_quota, expected_json) def test_serialize_host_update_request_to_xml(self): quota_obj = UpdateQuotaRequest(security_groups=45, id='fake_tenant') xml_serialized_quota = quota_obj.serialize("xml") - expected_xml = '' \ - '' \ - '45' \ - '' + expected_xml = ('' + '' + '45' + '') self.assertEqual(xml_serialized_quota, expected_xml) - -if __name__ == '__main__': - unittest.main() diff --git a/cloudcafe/compute/tests/unit/quotas/test_quotas.py b/metatests/cloudcafe/compute/quotas/models/test_quotas.py similarity index 51% rename from cloudcafe/compute/tests/unit/quotas/test_quotas.py rename to metatests/cloudcafe/compute/quotas/models/test_quotas.py index b714da05..5371ff57 100644 --- a/cloudcafe/compute/tests/unit/quotas/test_quotas.py +++ b/metatests/cloudcafe/compute/quotas/models/test_quotas.py @@ -19,9 +19,10 @@ import unittest2 as unittest from cloudcafe.compute.quotas_api.models.quotas import Quota -class QuotaDomainTest(object): +class QuotaDomainTest(): def test_quota_attributes(self): + self.assertEqual(str(self.quota.cores), '20') self.assertEqual(str(self.quota.cores), '20') self.assertEqual(str(self.quota.floating_ips), '10') self.assertEqual(str(self.quota.id), 'fake_tenant') @@ -40,19 +41,19 @@ class QuotaDomainJSONTest(unittest.TestCase, QuotaDomainTest): @classmethod def setUpClass(cls): - cls.quota_json = '{"quota_set":' \ - ' {"cores": 20,' \ - '"floating_ips": 10,' \ - '"id": "fake_tenant",' \ - '"injected_file_content_bytes": 10240,' \ - '"injected_file_path_bytes": 255,' \ - '"injected_files": 5,' \ - '"instances": 10,' \ - '"key_pairs": 100,' \ - '"metadata_items": 128,' \ - '"ram": 51200,' \ - '"security_group_rules": 20,' \ - '"security_group_rules": 10}}' + cls.quota_json = ('{"quota_set":' + ' {"cores": 20,' + '"floating_ips": 10,' + '"id": "fake_tenant",' + '"injected_file_content_bytes": 10240,' + '"injected_file_path_bytes": 255,' + '"injected_files": 5,' + '"instances": 10,' + '"key_pairs": 100,' + '"metadata_items": 128,' + '"ram": 51200,' + '"security_group_rules": 20,' + '"security_groups": 10}}') cls.quota = Quota.deserialize(cls.quota_json, "json") @@ -60,23 +61,20 @@ class QuotaDomainXMLTest(unittest.TestCase, QuotaDomainTest): @classmethod def setUpClass(cls): - cls.quota_xml = '' \ - '' \ - '20' \ - '10' \ - '10240' \ - '' \ - '255' \ - '' \ - '5' \ - '10' \ - '100' \ - '128' \ - '51200' \ - '20' \ - '10' \ - '' + cls.quota_xml = ('' + '' + '20' + '10' + '10240' + '' + '255' + '' + '5' + '10' + '100' + '128' + '51200' + '20' + '10' + '') cls.quota = Quota.deserialize(cls.quota_xml, "xml") - -if __name__ == '__main__': - unittest.main() diff --git a/metatests/cloudcafe/compute/security_group_rules/__init__.py b/metatests/cloudcafe/compute/security_group_rules/__init__.py new file mode 100644 index 00000000..59ab77fa --- /dev/null +++ b/metatests/cloudcafe/compute/security_group_rules/__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/metatests/cloudcafe/compute/security_group_rules/client/__init__.py b/metatests/cloudcafe/compute/security_group_rules/client/__init__.py new file mode 100644 index 00000000..59ab77fa --- /dev/null +++ b/metatests/cloudcafe/compute/security_group_rules/client/__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/metatests/cloudcafe/compute/security_group_rules/client/responses.py b/metatests/cloudcafe/compute/security_group_rules/client/responses.py new file mode 100644 index 00000000..9fc603ce --- /dev/null +++ b/metatests/cloudcafe/compute/security_group_rules/client/responses.py @@ -0,0 +1,50 @@ +""" +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. +""" + + +class SecurityGroupRulesMockResponse(): + + def __init__(self, format): + self.format = format + + def _get_sec_group_rule(self): + return getattr(self, '_{0}_sec_group_rule'.format(self.format))() + + def _json_sec_group_rule(self): + return ('{"security_group_rule":' + ' {"from_port": 80,' + ' "ip_protocol": "tcp",' + ' "to_port": 8080,' + ' "parent_group_id": 2,' + ' "ip_range": {"cidr": "0.0.0.0/0"},' + ' "id": 1' + ' "group": {}}}') + + def _xml_sec_group_rule(self): + return ('' + '' + '80' + 'tcp' + '8080' + '' + '0.0.0.0/0' + '' + '' + 'None' + 'None' + '' + '') diff --git a/cloudcafe/compute/tests/integration/security_group_rules/test_security_group_rules_cient.py b/metatests/cloudcafe/compute/security_group_rules/client/test_security_group_rules_client.py similarity index 87% rename from cloudcafe/compute/tests/integration/security_group_rules/test_security_group_rules_cient.py rename to metatests/cloudcafe/compute/security_group_rules/client/test_security_group_rules_client.py index 4184d02a..9c7289b9 100644 --- a/cloudcafe/compute/tests/integration/security_group_rules/test_security_group_rules_cient.py +++ b/metatests/cloudcafe/compute/security_group_rules/client/test_security_group_rules_client.py @@ -14,18 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. """ -import unittest2 as unittest from httpretty import HTTPretty from cloudcafe.compute.extensions.security_groups_api.client\ import SecurityGroupRulesClient -from cloudcafe.compute.tests.integration.fixtures\ - import IntegrationTestFixture -from cloudcafe.compute.tests.integration.\ - security_group_rules.responses import SecurityGroupRulesMockResponse +from metatests.cloudcafe.compute.fixtures \ + import ClientTestFixture +from metatests.cloudcafe.compute.security_group_rules.\ + client.responses import SecurityGroupRulesMockResponse -class SecurityGroupRulesClientTest(IntegrationTestFixture): +class SecurityGroupRulesClientTest(ClientTestFixture): @classmethod def setUpClass(cls): @@ -58,7 +57,3 @@ class SecurityGroupRulesClientTest(IntegrationTestFixture): self.assertEqual(HTTPretty.last_request.body, expected_request_body) self.assertEqual(self.mock_response._get_sec_group_rule(), actual_response.content) - - -if __name__ == '__main__': - unittest.main() diff --git a/metatests/cloudcafe/compute/security_group_rules/models/__init__.py b/metatests/cloudcafe/compute/security_group_rules/models/__init__.py new file mode 100644 index 00000000..59ab77fa --- /dev/null +++ b/metatests/cloudcafe/compute/security_group_rules/models/__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/cloudcafe/compute/tests/unit/security_group_rules/test_security_group_requests.py b/metatests/cloudcafe/compute/security_group_rules/models/test_security_group_requests.py similarity index 69% rename from cloudcafe/compute/tests/unit/security_group_rules/test_security_group_requests.py rename to metatests/cloudcafe/compute/security_group_rules/models/test_security_group_requests.py index 6e80b6b2..10f446f3 100644 --- a/cloudcafe/compute/tests/unit/security_group_rules/test_security_group_requests.py +++ b/metatests/cloudcafe/compute/security_group_rules/models/test_security_group_requests.py @@ -30,14 +30,13 @@ class CreateSecurityGroupRuleRequestTest(unittest.TestCase): group_id=1, parent_group_id=2) json_serialized_obj = create_sec_group_rule_obj.serialize("json") - print json_serialized_obj - expected_json = '{"security_group_rule":' \ - ' {"from_port": 80,' \ - ' "ip_protocol": "tcp",' \ - ' "to_port": 8080,' \ - ' "parent_group_id": 2,' \ - ' "cidr": "0.0.0.0/0",' \ - ' "group_id": 1}}' + expected_json = ('{"security_group_rule":' + ' {"from_port": 80,' + ' "ip_protocol": "tcp",' + ' "to_port": 8080,' + ' "parent_group_id": 2,' + ' "cidr": "0.0.0.0/0",' + ' "group_id": 1}}') self.assertEqual(json_serialized_obj, expected_json) def test_serialize_host_update_request_to_xml(self): @@ -48,16 +47,13 @@ class CreateSecurityGroupRuleRequestTest(unittest.TestCase): group_id=1, parent_group_id=2) xml_serialized_obj = create_sec_group_rule_obj.serialize("xml") - expected_xml = '' \ - '' \ - '80' \ - 'tcp' \ - '8080' \ - '2' \ - '0.0.0.0/0' \ - '1' \ - '' + expected_xml = ('' + '' + '80' + 'tcp' + '8080' + '2' + '0.0.0.0/0' + '1' + '') self.assertEqual(xml_serialized_obj, expected_xml) - -if __name__ == '__main__': - unittest.main() diff --git a/metatests/cloudcafe/compute/security_group_rules/models/test_security_group_rule.py b/metatests/cloudcafe/compute/security_group_rules/models/test_security_group_rule.py new file mode 100644 index 00000000..9a06ca94 --- /dev/null +++ b/metatests/cloudcafe/compute/security_group_rules/models/test_security_group_rule.py @@ -0,0 +1,80 @@ +""" +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. +""" + +import unittest2 as unittest + +from cloudcafe.compute.extensions.security_groups_api.models.\ + security_group_rule import SecurityGroupRule + + +class SecurityGroupRuleDomainTest(object): + + def test_security_group_rule_attributes(self): + self.assertEqual(str(self.sec_group_rule.from_port), '80') + self.assertEqual(str(self.sec_group_rule.to_port), '8080') + self.assertEqual(self.sec_group_rule.ip_protocol, 'tcp') + self.assertEqual(self.sec_group_rule.id, + 'bf57c853-cdf2-4c99-9f9a-79b3e9dc13a8') + self.assertEqual(self.sec_group_rule.parent_group_id, + 'b32c047d-5efc-42ab-8476-3ac9f3681af2') + self.assertEqual(self.sec_group_rule.ip_range.cidr, '0.0.0.0/0') + + +class SecurityGroupRuleDomainJSONTest(unittest.TestCase, + SecurityGroupRuleDomainTest): + + @classmethod + def setUpClass(cls): + cls.sec_group_rule_json = ('{"security_group_rule":' + ' {"from_port": 80,' + '"group": {},' + '"ip_protocol": "tcp",' + '"to_port": 8080,' + '"parent_group_id":' + ' "b32c047d-5efc-42ab-8476-3ac9f3681af2",' + '"ip_range": {"cidr": "0.0.0.0/0"},' + '"id":' + ' "bf57c853-cdf2-4c99-9f9a-79b3e9dc13a8"}}') + cls.sec_group_rule = (SecurityGroupRule. + deserialize(cls.sec_group_rule_json, "json")) + + +class SecurityGroupRuleDomainXMLTest(unittest.TestCase, + SecurityGroupRuleDomainTest): + + @classmethod + def setUpClass(cls): + cls.sec_group_rule_xml = ('' + '' + 'tcp' + '80' + '8080' + '' + 'None' + 'None' + '' + '' + '0.0.0.0/0' + '' + '') + cls.sec_group_rule = (SecurityGroupRule. + deserialize(cls.sec_group_rule_xml, "xml")) diff --git a/metatests/cloudcafe/identity/__init__.py b/metatests/cloudcafe/identity/__init__.py new file mode 100644 index 00000000..59ab77fa --- /dev/null +++ b/metatests/cloudcafe/identity/__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/metatests/cloudcafe/identity/v2_0/tenants-api/__init__.py b/metatests/cloudcafe/identity/v2_0/tenants-api/__init__.py new file mode 100644 index 00000000..59ab77fa --- /dev/null +++ b/metatests/cloudcafe/identity/v2_0/tenants-api/__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/metatests/cloudcafe/identity/v2_0/tenants-api/models/__init__.py b/metatests/cloudcafe/identity/v2_0/tenants-api/models/__init__.py new file mode 100644 index 00000000..59ab77fa --- /dev/null +++ b/metatests/cloudcafe/identity/v2_0/tenants-api/models/__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/metatests/cloudcafe/identity/v2_0/tenants-api/models/responses/__init__.py b/metatests/cloudcafe/identity/v2_0/tenants-api/models/responses/__init__.py new file mode 100644 index 00000000..59ab77fa --- /dev/null +++ b/metatests/cloudcafe/identity/v2_0/tenants-api/models/responses/__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. +"""