def testServiceCatalogMonascaUrlUsingDefaults(self): Keystone.instance = None with mock.patch('keystoneclient.v3.client.Client') as client: config = base_config.get_config('Api') keystone = Keystone(config) keystone.get_monasca_url() self.assertTrue(client.called) self.assertIn('auth_url', client.call_args[client.call_count]) self.assertNotIn('service_type', client.call_args[client.call_count]) self.assertNotIn('endpoint_type', client.call_args[client.call_count]) self.assertNotIn('region_name', client.call_args[client.call_count]) client.return_value.service_catalog.url_for.assert_has_calls([ mock.call(endpoint_type=self.default_endpoint_type, service_type=self.default_service_type) ])
def testServiceCatalogMonascaUrlWithCustomRegionName(self): Keystone.instance = None region_name = 'my_region' with mock.patch('keystoneclient.v3.client.Client') as client: config = base_config.get_config('Api') config.update({'region_name': region_name}) keystone = Keystone(config) keystone.get_monasca_url() self.assertTrue(client.called) self.assertIn('auth_url', client.call_args[client.call_count]) self.assertNotIn('service_type', client.call_args[client.call_count]) self.assertNotIn('endpoint_type', client.call_args[client.call_count]) self.assertNotIn('region_name', client.call_args[client.call_count]) client.return_value.service_catalog.url_for.assert_has_calls([ mock.call(endpoint_type=self.default_endpoint_type, service_type=self.default_service_type, attr='region', filter_value=region_name) ])