/opt/imh-python/lib/python3.9/site-packages/openstack/tests/unit/cloud
NameSizeModeActions
__pycache__/-0755rm
test_accelerator.py113460644editdlrm
test_aggregate.py71530644editdlrm
test_availability_zones.py23080644editdlrm
test_baremetal_node.py689580644editdlrm
test_baremetal_ports.py43560644editdlrm
test_caching.py250600644editdlrm
test_clustering.py256410644editdlrm
test_cluster_templates.py99460644editdlrm
test_coe_clusters.py61180644editdlrm
test_coe_clusters_certificate.py25650644editdlrm
test_create_server.py395140644editdlrm
test_create_volume_snapshot.py55710644editdlrm
test_delete_server.py106220644editdlrm
test_delete_volume_snapshot.py40400644editdlrm
test_domains.py98580644editdlrm
test_domain_params.py29030644editdlrm
test_endpoints.py160350644editdlrm
test_flavors.py118610644editdlrm
test_floating_ip_common.py82700644editdlrm
test_floating_ip_neutron.py489720644editdlrm
test_floating_ip_nova.py111220644editdlrm
test_floating_ip_pool.py28860644editdlrm
test_fwaas.py523430644editdlrm
test_groups.py38860644editdlrm
test_identity_roles.py122360644editdlrm
test_image.py606010644editdlrm
test_image_snapshot.py41710644editdlrm
test_inventory.py58260644editdlrm
test_keypair.py49100644editdlrm
test_limits.py39290644editdlrm
test_magnum_services.py13780644editdlrm
test_meta.py431550644editdlrm
test_network.py140950644editdlrm
test_normalize.py583390644editdlrm
test_object.py513270644editdlrm
test_operator.py64880644editdlrm
test_operator_noauth.py81880644editdlrm
test_port.py142850644editdlrm
test_project.py111560644editdlrm
test_qos_bandwidth_limit_rule.py173270644editdlrm
test_qos_dscp_marking_rule.py122240644editdlrm
test_qos_minimum_bandwidth_rule.py123990644editdlrm
test_qos_policy.py132440644editdlrm
test_qos_rule_type.py56480644editdlrm
test_quotas.py93880644editdlrm
test_rebuild_server.py94790644editdlrm
test_recordset.py147670644editdlrm
test_role_assignment.py1502820644editdlrm
test_router.py171070644editdlrm
test_security_groups.py325700644editdlrm
test_server_console.py28460644editdlrm
test_server_delete_metadata.py26910644editdlrm
test_server_group.py23660644editdlrm
test_server_set_metadata.py27840644editdlrm
test_services.py117000644editdlrm
test_shade.py270600644editdlrm
test_shade_operator.py7430644editdlrm
test_stack.py264530644editdlrm
test_subnet.py185810644editdlrm
test_update_server.py33390644editdlrm
test_usage.py25950644editdlrm
test_users.py90440644editdlrm
test_volume.py235050644editdlrm
test_volume_access.py85560644editdlrm
test_volume_backups.py89470644editdlrm
test_zone.py76350644editdlrm
test__utils.py138570644editdlrm
__init__.py00644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/openstack/tests/unit/cloud/test_cluster_templates.py (9946B)
# 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 munch import openstack.cloud import testtools from openstack.tests.unit import base cluster_template_obj = munch.Munch( apiserver_port=12345, cluster_distro='fake-distro', coe='fake-coe', created_at='fake-date', dns_nameserver='8.8.8.8', docker_volume_size=1, external_network_id='public', fixed_network=None, flavor_id='fake-flavor', https_proxy=None, human_id=None, image_id='fake-image', insecure_registry='https://192.168.0.10', keypair_id='fake-key', labels={}, links={}, master_flavor_id=None, name='fake-cluster-template', network_driver='fake-driver', no_proxy=None, public=False, registry_enabled=False, server_type='vm', tls_disabled=False, updated_at=None, uuid='fake-uuid', volume_driver=None, ) class TestClusterTemplates(base.TestCase): def get_mock_url( self, service_type='container-infrastructure-management', base_url_append=None, append=None, resource=None): return super(TestClusterTemplates, self).get_mock_url( service_type=service_type, resource=resource, append=append, base_url_append=base_url_append) def test_list_cluster_templates_without_detail(self): self.register_uris([ dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='GET', uri=self.get_mock_url(resource='baymodels/detail'), json=dict(baymodels=[cluster_template_obj.toDict()]))]) cluster_templates_list = self.cloud.list_cluster_templates() self.assertEqual( cluster_templates_list[0], self.cloud._normalize_cluster_template(cluster_template_obj)) self.assert_calls() def test_list_cluster_templates_with_detail(self): self.register_uris([ dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='GET', uri=self.get_mock_url(resource='baymodels/detail'), json=dict(baymodels=[cluster_template_obj.toDict()]))]) cluster_templates_list = self.cloud.list_cluster_templates(detail=True) self.assertEqual( cluster_templates_list[0], self.cloud._normalize_cluster_template(cluster_template_obj)) self.assert_calls() def test_search_cluster_templates_by_name(self): self.register_uris([ dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='GET', uri=self.get_mock_url(resource='baymodels/detail'), json=dict(baymodels=[cluster_template_obj.toDict()]))]) cluster_templates = self.cloud.search_cluster_templates( name_or_id='fake-cluster-template') self.assertEqual(1, len(cluster_templates)) self.assertEqual('fake-uuid', cluster_templates[0]['uuid']) self.assert_calls() def test_search_cluster_templates_not_found(self): self.register_uris([ dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='GET', uri=self.get_mock_url(resource='baymodels/detail'), json=dict(baymodels=[cluster_template_obj.toDict()]))]) cluster_templates = self.cloud.search_cluster_templates( name_or_id='non-existent') self.assertEqual(0, len(cluster_templates)) self.assert_calls() def test_get_cluster_template(self): self.register_uris([ dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='GET', uri=self.get_mock_url(resource='baymodels/detail'), json=dict(baymodels=[cluster_template_obj.toDict()]))]) r = self.cloud.get_cluster_template('fake-cluster-template') self.assertIsNotNone(r) self.assertDictEqual( r, self.cloud._normalize_cluster_template(cluster_template_obj)) self.assert_calls() def test_get_cluster_template_not_found(self): self.register_uris([ dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='GET', uri=self.get_mock_url(resource='baymodels/detail'), json=dict(baymodels=[]))]) r = self.cloud.get_cluster_template('doesNotExist') self.assertIsNone(r) self.assert_calls() def test_create_cluster_template(self): json_response = cluster_template_obj.toDict() kwargs = dict(name=cluster_template_obj.name, image_id=cluster_template_obj.image_id, keypair_id=cluster_template_obj.keypair_id, coe=cluster_template_obj.coe) self.register_uris([ dict( method='POST', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='POST', uri=self.get_mock_url(resource='baymodels'), json=json_response, validate=dict(json=kwargs)), ]) expected = self.cloud._normalize_cluster_template(json_response) response = self.cloud.create_cluster_template(**kwargs) self.assertEqual(response, expected) self.assert_calls() def test_create_cluster_template_exception(self): self.register_uris([ dict( method='POST', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='POST', uri=self.get_mock_url(resource='baymodels'), status_code=403)]) # TODO(mordred) requests here doens't give us a great story # for matching the old error message text. Investigate plumbing # an error message in to the adapter call so that we can give a # more informative error. Also, the test was originally catching # OpenStackCloudException - but for some reason testtools will not # match the more specific HTTPError, even though it's a subclass # of OpenStackCloudException. with testtools.ExpectedException( openstack.cloud.OpenStackCloudHTTPError): self.cloud.create_cluster_template('fake-cluster-template') self.assert_calls() def test_delete_cluster_template(self): self.register_uris([ dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='GET', uri=self.get_mock_url(resource='baymodels/detail'), json=dict(baymodels=[cluster_template_obj.toDict()])), dict( method='DELETE', uri=self.get_mock_url(resource='baymodels/fake-uuid')), ]) self.cloud.delete_cluster_template('fake-uuid') self.assert_calls() def test_update_cluster_template(self): self.register_uris([ dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), status_code=404), dict( method='GET', uri=self.get_mock_url(resource='baymodels/detail'), json=dict(baymodels=[cluster_template_obj.toDict()])), dict( method='PATCH', uri=self.get_mock_url(resource='baymodels/fake-uuid'), status_code=200, validate=dict( json=[{ u'op': u'replace', u'path': u'/name', u'value': u'new-cluster-template' }] )), dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), # This json value is not meaningful to the test - it just has # to be valid. json=dict(baymodels=[cluster_template_obj.toDict()])), ]) new_name = 'new-cluster-template' self.cloud.update_cluster_template( 'fake-uuid', 'replace', name=new_name) self.assert_calls() def test_get_coe_cluster_template(self): self.register_uris([ dict( method='GET', uri=self.get_mock_url(resource='clustertemplates'), json=dict(clustertemplates=[cluster_template_obj.toDict()]))]) r = self.cloud.get_coe_cluster_template('fake-cluster-template') self.assertIsNotNone(r) self.assertDictEqual( r, self.cloud._normalize_cluster_template(cluster_template_obj)) self.assert_calls()