def __init__(self, *args, **kwargs): """Initialize a new client for the Murano v1 API.""" self.glance_client = kwargs.pop('glance_client', None) tenant = kwargs.pop('tenant', None) self.http_client = http._construct_http_client(*args, **kwargs) self.environments = environments.EnvironmentManager(self.http_client) self.env_templates = templates.EnvTemplateManager(self.http_client) self.sessions = sessions.SessionManager(self.http_client) self.services = services.ServiceManager(self.http_client) self.deployments = deployments.DeploymentManager(self.http_client) self.request_statistics = \ request_statistics.RequestStatisticsManager(self.http_client) self.instance_statistics = \ instance_statistics.InstanceStatisticsManager(self.http_client) artifacts_client = kwargs.pop('artifacts_client', None) pkg_mgr = packages.PackageManager(self.http_client) if artifacts_client: artifact_repo = artifact_packages.ArtifactRepo( artifacts_client, tenant) self.packages = artifact_packages.PackageManagerAdapter( pkg_mgr, artifact_repo) else: self.packages = pkg_mgr self.actions = actions.ActionManager(self.http_client) self.categories = categories.CategoryManager(self.http_client)
def test_package_filter_pagination_next_marker(self): """``PackageManager.filter`` handles `next_marker` parameter related to pagination in API correctly. """ responses = [{ 'next_marker': 'test_marker', 'packages': [{ 'name': 'test_package_1' }] }, { 'packages': [{ 'name': 'test_package_2' }] }] def json_request(method, url, *args, **kwargs): self.assertIn('/v1/catalog/packages', url) return mock.MagicMock(), responses.pop(0) api = mock.MagicMock() api.configure_mock(**{'json_request.side_effect': json_request}) manager = packages.PackageManager(api) list(manager.filter()) self.assertEqual(2, api.json_request.call_count)
def test_package_filter_encoding_good(self): responses = [{ 'next_marker': 'test_marker', 'packages': [{ 'name': 'test_package_1' }] }, { 'packages': [{ 'name': 'test_package_2' }] }] def json_request(method, url, *args, **kwargs): self.assertIn('category=%D0%BF%D0%B8%D0%B2%D0%BE', url) return mock.MagicMock(), responses.pop(0) api = mock.MagicMock() api.configure_mock(**{'json_request.side_effect': json_request}) manager = packages.PackageManager(api) category = six.b('\xd0\xbf\xd0\xb8\xd0\xb2\xd0\xbe') kwargs = {'category': category.decode('utf-8')} list(manager.filter(**kwargs)) self.assertEqual(2, api.json_request.call_count)
def __init__(self, *args, **kwargs): """ Initialize a new client for the Murano v1 API. """ super(Client, self).__init__(*args, **kwargs) self.environments = environments.EnvironmentManager(self) self.sessions = sessions.SessionManager(self) self.services = services.ServiceManager(self) self.deployments = deployments.DeploymentManager(self) self.request_statistics = \ request_statistics.RequestStatisticsManager(self) self.instance_statistics = \ instance_statistics.InstanceStatisticsManager(self) self.packages = packages.PackageManager(self)