• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python api.package_search函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中murano.db.catalog.api.package_search函数的典型用法代码示例。如果您正苦于以下问题:Python package_search函数的具体用法?Python package_search怎么用?Python package_search使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了package_search函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_package_search_no_filters

    def test_package_search_no_filters(self):
        res = api.package_search({}, self.context)
        self.assertEqual(0, len(res))

        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                is_public=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)
        api.package_upload(
            self._stub_package(
                is_public=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)

        # I can only edit mine pkgs
        res = api.package_search({}, self.context)
        self.assertEqual(2, len(res))
        for pkg in res:
            self.assertEqual(self.tenant_id, pkg.owner_id)

        # Admin can see everything
        res = api.package_search({}, self.context_admin)
        self.assertEqual(4, len(res))
开发者ID:Aqsamm,项目名称:murano,代码行数:31,代码来源:test_catalog.py


示例2: test_pagination_loops_through_names

    def test_pagination_loops_through_names(self):
        """Tests that packages with same display name are not skipped

        Creates 10 packages with the same display name and iterates
        through them, checking that package are not skipped.
        """

        for dummy in range(10):
            api.package_upload(
                self._stub_package(name='test',
                                   fully_qualified_name=str(uuid.uuid4())),
                self.tenant_id)
        res = api.package_search({}, self.context, limit=4)
        self.assertEqual(4, len(res))
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(4, len(res))
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(2, len(res))
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(0, len(res))
开发者ID:AleptNamrata,项目名称:murano,代码行数:26,代码来源:test_catalog.py


示例3: test_pagination_backwards

    def test_pagination_backwards(self):
        """Creates 10 packages with unique names and iterates backwards,
        checking that package order is correct.
        """
        pkgs = []
        for dummy in range(10):
            package = api.package_upload(
                self._stub_package(name=str(uuid.uuid4()), fully_qualified_name=str(uuid.uuid4())), self.tenant_id
            )
            pkgs.append(package)

        # sort pkg ids by pkg name
        pkg_ids = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.name)]

        res = api.package_search({}, self.context, limit=10)
        self.assertEqual(10, len(res))
        self.assertEqual(pkg_ids, [r.id for r in res])
        marker = res[-1].id

        res = api.package_search({"marker": marker, "sort_dir": "desc"}, self.context, limit=5)
        self.assertEqual(5, len(res))
        self.assertEqual(list(reversed(pkg_ids[4:9])), [r.id for r in res])
        marker = res[-1].id

        res = api.package_search({"marker": marker, "sort_dir": "desc"}, self.context, limit=5)
        self.assertEqual(4, len(res))
        self.assertEqual(list(reversed(pkg_ids[0:4])), [r.id for r in res])
        marker = res[-1].id

        res = api.package_search({"marker": marker, "sort_dir": "desc"}, self.context, limit=5)
        self.assertEqual(0, len(res))
开发者ID:NikolayStarodubtsev,项目名称:murano,代码行数:31,代码来源:test_catalog.py


示例4: test_pagination

    def test_pagination(self):
        """Creates 10 packages with unique names and iterates through them,
        checking that package order is correct.
        """

        pkgs = []
        for dummy in range(10):
            package = api.package_upload(self._stub_package(
                name=str(uuid.uuid4()),
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
            pkgs.append(package)

        # sort pkg ids by pkg name
        pkg_ids = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.name)]

        res = api.package_search({}, self.context, limit=4)
        self.assertEqual(4, len(res))
        self.assertEqual(pkg_ids[0:4], [r.id for r in res])
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(4, len(res))
        self.assertEqual(pkg_ids[4:8], [r.id for r in res])
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(2, len(res))
        self.assertEqual(pkg_ids[8:10], [r.id for r in res])
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(0, len(res))
开发者ID:Aqsamm,项目名称:murano,代码行数:32,代码来源:test_catalog.py


示例5: test_package_search_no_filters_catalog

    def test_package_search_no_filters_catalog(self):
        res = api.package_search({}, self.context, catalog=True)
        self.assertEqual(0, len(res))

        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                is_public=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)
        api.package_upload(
            self._stub_package(
                is_public=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)

        # catalog=True should show public + mine
        res = api.package_search({}, self.context, catalog=True)
        self.assertEqual(3, len(res))

        res = api.package_search({}, self.context_admin, catalog=True)
        self.assertEqual(3, len(res))
开发者ID:Aqsamm,项目名称:murano,代码行数:28,代码来源:test_catalog.py


示例6: test_package_search_search

    def test_package_search_search(self):
        pkg1 = api.package_upload(
            self._stub_package(
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        pkg2 = api.package_upload(
            self._stub_package(
                tags=[],
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search(
            {'search': 'tag1'}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'search': pkg1.fully_qualified_name}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'search': pkg2.fully_qualified_name}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'search': 'not_a_valid_uuid'}, self.context)
        self.assertEqual(0, len(res))

        res = api.package_search(
            {'search': 'some text'}, self.context)
        self.assertEqual(2, len(res))
开发者ID:Aqsamm,项目名称:murano,代码行数:25,代码来源:test_catalog.py


示例7: test_package_search_owned

    def test_package_search_owned(self):
        api.package_upload(self._stub_package(is_public=True, fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(self._stub_package(is_public=True, fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)

        res = api.package_search({"owned": "true"}, self.context_admin)
        self.assertEqual(1, len(res))
        res = api.package_search({"owned": "false"}, self.context_admin)
        self.assertEqual(2, len(res))
开发者ID:NikolayStarodubtsev,项目名称:murano,代码行数:8,代码来源:test_catalog.py


示例8: test_package_search_type

    def test_package_search_type(self):
        api.package_upload(
            self._stub_package(type="Application", fully_qualified_name=str(uuid.uuid4())), self.tenant_id
        )
        api.package_upload(self._stub_package(type="Library", fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search({"type": "Library"}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search({"type": "Application"}, self.context)
        self.assertEqual(1, len(res))
开发者ID:NikolayStarodubtsev,项目名称:murano,代码行数:10,代码来源:test_catalog.py


示例9: test_package_search_tags

    def test_package_search_tags(self):
        api.package_upload(self._stub_package(fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(self._stub_package(tags=[], fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search({"tag": ["tag1"]}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search({"tag": ["tag2"]}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search({"tag": ["tag3"]}, self.context)
        self.assertEqual(0, len(res))
开发者ID:NikolayStarodubtsev,项目名称:murano,代码行数:10,代码来源:test_catalog.py


示例10: test_package_search_disabled

    def test_package_search_disabled(self):
        api.package_upload(
            self._stub_package(is_public=True, enabled=True, fully_qualified_name=str(uuid.uuid4())), self.tenant_id
        )
        api.package_upload(
            self._stub_package(is_public=True, enabled=False, fully_qualified_name=str(uuid.uuid4())), self.tenant_id
        )

        res = api.package_search({"include_disabled": "false"}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search({"include_disabled": "true"}, self.context)
        self.assertEqual(2, len(res))
开发者ID:NikolayStarodubtsev,项目名称:murano,代码行数:12,代码来源:test_catalog.py


示例11: test_package_search_owned

    def test_package_search_owned(self):
        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)

        res = api.package_search({'owned': 'true'}, self.context_admin)
        self.assertEqual(len(res), 1)
        res = api.package_search({'owned': 'false'}, self.context_admin)
        self.assertEqual(len(res), 2)
开发者ID:aawm,项目名称:murano,代码行数:14,代码来源:test_catalog.py


示例12: test_package_search_search

    def test_package_search_search(self):
        pkg1 = api.package_upload(self._stub_package(fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        pkg2 = api.package_upload(self._stub_package(tags=[], fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search({"search": "tag1"}, self.context)
        self.assertEqual(len(res), 1)
        res = api.package_search({"search": pkg1.fully_qualified_name}, self.context)
        self.assertEqual(len(res), 1)
        res = api.package_search({"search": pkg2.fully_qualified_name}, self.context)
        self.assertEqual(len(res), 1)
        res = api.package_search({"search": "not_a_valid_uuid"}, self.context)
        self.assertEqual(len(res), 0)

        res = api.package_search({"search": "some text"}, self.context)
        self.assertEqual(len(res), 2)
开发者ID:chenyujie,项目名称:hybrid-murano,代码行数:15,代码来源:test_catalog.py


示例13: search

    def search(self, req):
        def _validate_limit(value):
            if value is None:
                return
            try:
                value = int(value)
            except ValueError:
                msg = _("limit param must be an integer")
                LOG.error(msg)
                raise exc.HTTPBadRequest(explanation=msg)

            if value <= 0:
                msg = _("limit param must be positive")
                LOG.error(msg)
                raise exc.HTTPBadRequest(explanation=msg)

            return value

        policy.check("search_packages", req.context)

        filters = _get_filters(req.GET.items())
        limit = _validate_limit(filters.get('limit'))
        if limit is None:
            limit = CONF.packages_opts.limit_param_default
        limit = min(CONF.packages_opts.api_limit_max, limit)

        result = {}
        packages = db_api.package_search(filters, req.context, limit)
        if len(packages) == limit:
            result['next_marker'] = packages[-1].id
        result['packages'] = [package.to_dict() for package in packages]
        return result
开发者ID:OndrejVojta,项目名称:murano,代码行数:32,代码来源:catalog.py


示例14: test_package_search_disabled

    def test_package_search_disabled(self):
        api.package_upload(
            self._stub_package(
                is_public=True,
                enabled=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                is_public=True,
                enabled=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search(
            {'include_disabled': 'false'}, self.context)
        self.assertEqual(len(res), 1)
        res = api.package_search(
            {'include_disabled': 'true'}, self.context)
        self.assertEqual(len(res), 2)
开发者ID:aawm,项目名称:murano,代码行数:18,代码来源:test_catalog.py


示例15: test_package_search_tags

    def test_package_search_tags(self):
        api.package_upload(
            self._stub_package(
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                tags=[],
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search(
            {'tag': ['tag1']}, self.context)
        self.assertEqual(len(res), 1)
        res = api.package_search(
            {'tag': ['tag2']}, self.context)
        self.assertEqual(len(res), 1)
        res = api.package_search(
            {'tag': ['tag3']}, self.context)
        self.assertEqual(len(res), 0)
开发者ID:aawm,项目名称:murano,代码行数:18,代码来源:test_catalog.py


示例16: list

    def list(self, req):

        packages = db_api.package_search({'type': 'application'},
                                         req.context,
                                         catalog=True)
        services = []
        for package in packages:
            services.append(self._package_to_service(package))

        resp = {'services': services}

        return resp
开发者ID:GovardhanSN,项目名称:murano,代码行数:12,代码来源:cfapi.py


示例17: test_pagination_loops_through_names

    def test_pagination_loops_through_names(self):
        """Creates 10 packages with the same name and iterates through them,
        checking that package are not skipped.
        """

        # TODO(kzaitsev): fix https://bugs.launchpad.net/murano/+bug/1448782
        for i in range(10):
            api.package_upload(self._stub_package(fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        res = api.package_search({}, self.context, limit=4)
        self.assertEqual(len(res), 4)
        marker = res[-1].id

        res = api.package_search({"marker": marker}, self.context, limit=4)
        self.assertEqual(len(res), 4)
        marker = res[-1].id

        res = api.package_search({"marker": marker}, self.context, limit=4)
        self.assertEqual(len(res), 2)
        marker = res[-1].id

        res = api.package_search({"marker": marker}, self.context, limit=4)
        self.assertEqual(len(res), 0)
开发者ID:chenyujie,项目名称:hybrid-murano,代码行数:22,代码来源:test_catalog.py


示例18: list

    def list(self, req):
        user, _, keystone = self._check_auth(req)
        # Once we get here we were authorized by keystone
        token = keystone.auth_token

        ctx = context.RequestContext(user=user, tenant='', auth_token=token)

        packages = db_api.package_search({'type': 'application'}, ctx,
                                         catalog=True)
        services = []
        for package in packages:
            services.append(self._package_to_service(package))

        resp = {'services': services}

        return resp
开发者ID:NikolayStarodubtsev,项目名称:murano,代码行数:16,代码来源:cfapi.py


示例19: test_order_by

    def test_order_by(self):
        pkgs = []
        for dummy in range(10):
            package = api.package_upload(
                self._stub_package(name=str(uuid.uuid4()), fully_qualified_name=str(uuid.uuid4())), self.tenant_id
            )
            pkgs.append(package)

        pkg_created = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.created)]
        pkg_name = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.name)]
        pkg_fqn = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.fully_qualified_name)]

        for order, pkg_ids in zip(["created", "name", "fqn"], [pkg_created, pkg_name, pkg_fqn]):
            res = api.package_search({"order_by": [order]}, self.context, limit=10)
            self.assertEqual(10, len(res))
            self.assertEqual(pkg_ids, [r.id for r in res])
开发者ID:NikolayStarodubtsev,项目名称:murano,代码行数:16,代码来源:test_catalog.py


示例20: _do_import_package

def _do_import_package(_dir, categories, update=False):
    LOG.debug("Going to import Murano package from {source}".format(
        source=_dir))
    pkg = load_utils.load_from_dir(_dir)

    LOG.debug("Checking for existing packages")
    existing = db_catalog_api.package_search(
        {'fqn': pkg.full_name},
        AdminContext())
    if existing:
        existing_pkg = existing[0]
        if update:
            LOG.debug('Deleting existing package {exst_pkg_id}').format(
                exst_pkg_id=existing_pkg.id)
            db_catalog_api.package_delete(existing_pkg.id, AdminContext())
        else:
            LOG.error(_LE("Package '{name}' exists ({pkg_id}). Use --update.")
                      .format(name=pkg.full_name, pkg_id=existing_pkg.id))
            return

    package = {
        'fully_qualified_name': pkg.full_name,
        'type': pkg.package_type,
        'author': pkg.author,
        'supplier': pkg.supplier,
        'name': pkg.display_name,
        'description': pkg.description,
        # note: we explicitly mark all the imported packages as public,
        # until a parameter added to control visibility scope of a package
        'is_public': True,
        'tags': pkg.tags,
        'logo': pkg.logo,
        'supplier_logo': pkg.supplier_logo,
        'ui_definition': pkg.ui,
        'class_definitions': pkg.classes,
        'archive': pkg.blob,
        'categories': categories or []
    }

    # note(ruhe): the second parameter is tenant_id
    # it is a required field in the DB, that's why we pass an empty string
    result = db_catalog_api.package_upload(package, '')

    LOG.info(_LI("Finished import of package {res_id}").format(
        res_id=result.id))
开发者ID:Aqsamm,项目名称:murano,代码行数:45,代码来源:manage.py



注:本文中的murano.db.catalog.api.package_search函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.package_upload函数代码示例发布时间:2022-05-27
下一篇:
Python api.package_get函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap