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

Python views.release_detail函数代码示例

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

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



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

示例1: test_no_license

    def test_no_license(self, db_request):
        """With no license classifier or metadata, no license is in context."""
        release = ReleaseFactory.create()

        result = views.release_detail(release, db_request)

        assert result["license"] is None
开发者ID:alex,项目名称:warehouse,代码行数:7,代码来源:test_views.py


示例2: test_multiline_license

    def test_multiline_license(self, db_request):
        """When license metadata is longer than one line, the first is used."""
        release = ReleaseFactory.create(license="Multiline License\nhow terrible")

        result = views.release_detail(release, db_request)

        assert result["license"] == "Multiline License"
开发者ID:craig5,项目名称:warehouse,代码行数:7,代码来源:test_views.py


示例3: test_license_with_no_classifier

    def test_license_with_no_classifier(self, db_request):
        """With no classifier, a license is used from metadata."""
        release = ReleaseFactory.create(license="MIT License")

        result = views.release_detail(release, db_request)

        assert result["license"] == "MIT License"
开发者ID:alex,项目名称:warehouse,代码行数:7,代码来源:test_views.py


示例4: test_detail_renders

    def test_detail_renders(self, monkeypatch, db_request):
        users = [
            UserFactory.create(),
            UserFactory.create(),
            UserFactory.create(),
        ]
        project = ProjectFactory.create()
        releases = [
            ReleaseFactory.create(
                project=project,
                version=v,
                description="unrendered description",
                description_content_type="text/plain")
            for v in ["1.0", "2.0", "3.0", "4.0.dev0"]
        ]
        files = [
            FileFactory.create(
                release=r,
                filename="{}-{}.tar.gz".format(project.name, r.version),
                python_version="source",
            )
            for r in releases
        ]

        # Create a role for each user
        for user in users:
            RoleFactory.create(user=user, project=project)

        # Add an extra role for one user, to ensure deduplication
        RoleFactory.create(
            user=users[0],
            project=project,
            role_name="another role",
        )

        # patch the readme rendering logic.
        render_description = pretend.call_recorder(
            lambda raw, content_type: "rendered description")
        monkeypatch.setattr(readme, "render", render_description)

        result = views.release_detail(releases[1], db_request)

        assert result == {
            "project": project,
            "release": releases[1],
            "files": [files[1]],
            "description": "rendered description",
            "latest_version": project.latest_version,
            "all_versions": [
                (r.version, r.created, r.is_prerelease)
                for r in reversed(releases)
            ],
            "maintainers": sorted(users, key=lambda u: u.username.lower()),
            "license": None
        }

        assert render_description.calls == [
            pretend.call("unrendered description", "text/plain")
        ]
开发者ID:mbacchi,项目名称:warehouse,代码行数:59,代码来源:test_views.py


示例5: test_detail_renders

    def test_detail_renders(self, db_request):
        users = [
            UserFactory.create(),
            UserFactory.create(),
            UserFactory.create(),
        ]
        project = ProjectFactory.create()
        releases = [
            ReleaseFactory.create(project=project, version=v)
            for v in ["1.0", "2.0", "3.0"]
        ]
        files = [
            FileFactory.create(
                release=r,
                filename="{}-{}.tar.gz".format(project.name, r.version),
                python_version="source",
            )
            for r in releases
        ]

        # Create a role for each user
        for user in users:
            RoleFactory.create(user=user, project=project)

        # Add an extra role for one user, to ensure deduplication
        RoleFactory.create(
            user=users[0],
            project=project,
            role_name="another role",
        )

        daily_stats = pretend.stub()
        weekly_stats = pretend.stub()
        monthly_stats = pretend.stub()

        db_request.find_service = lambda x: pretend.stub(
            get_daily_stats=lambda p: daily_stats,
            get_weekly_stats=lambda p: weekly_stats,
            get_monthly_stats=lambda p: monthly_stats,
        )

        result = views.release_detail(releases[1], db_request)

        assert result == {
            "project": project,
            "release": releases[1],
            "files": [files[1]],
            "all_releases": [
                (r.version, r.created) for r in reversed(releases)
            ],
            "maintainers": sorted(users, key=lambda u: u.username.lower()),
            "download_stats": {
                "daily": daily_stats,
                "weekly": weekly_stats,
                "monthly": monthly_stats,
            },
        }
开发者ID:maxking,项目名称:warehouse,代码行数:57,代码来源:test_views.py


示例6: test_multiple_licenses_from_classifiers

    def test_multiple_licenses_from_classifiers(self, db_request):
        """A license label is added when multiple license classifiers exist."""
        license_1 = ClassifierFactory.create(
            classifier="License :: OSI Approved :: BSD License")
        license_2 = ClassifierFactory.create(
            classifier="License :: OSI Approved :: MIT License")
        release = ReleaseFactory.create(_classifiers=[license_1, license_2])

        result = views.release_detail(release, db_request)

        assert result["license"] == "BSD License, MIT License"
开发者ID:alex,项目名称:warehouse,代码行数:11,代码来源:test_views.py


示例7: test_detail_renders

    def test_detail_renders(self, db_request):
        users = [
            UserFactory.create(),
            UserFactory.create(),
            UserFactory.create(),
        ]
        project = ProjectFactory.create()
        releases = [
            ReleaseFactory.create(project=project, version=v)
            for v in ["1.0", "2.0", "3.0", "4.0.dev0"]
        ]
        latest_release = first(
            reversed(releases),
            key=lambda r: not r.is_prerelease,
        )
        files = [
            FileFactory.create(
                release=r,
                filename="{}-{}.tar.gz".format(project.name, r.version),
                python_version="source",
            )
            for r in releases
        ]

        # Create a role for each user
        for user in users:
            RoleFactory.create(user=user, project=project)

        # Add an extra role for one user, to ensure deduplication
        RoleFactory.create(
            user=users[0],
            project=project,
            role_name="another role",
        )

        result = views.release_detail(releases[1], db_request)

        assert result == {
            "project": project,
            "release": releases[1],
            "files": [files[1]],
            "latest_release": (
                latest_release.version,
                latest_release.is_prerelease,
                latest_release.created,
            ),
            "all_releases": [
                (r.version, r.is_prerelease, r.created)
                for r in reversed(releases)
            ],
            "maintainers": sorted(users, key=lambda u: u.username.lower()),
            "license": None
        }
开发者ID:alex,项目名称:warehouse,代码行数:53,代码来源:test_views.py


示例8: test_license_from_classifier

    def test_license_from_classifier(self, db_request):
        """A license label is added when a license classifier exists."""
        other_classifier = ClassifierFactory.create(
            classifier="Some :: Random :: Classifier")
        classifier = ClassifierFactory.create(
            classifier="License :: OSI Approved :: BSD License")
        release = ReleaseFactory.create(
            _classifiers=[other_classifier, classifier],
            license="Will not be used")

        result = views.release_detail(release, db_request)

        assert result["license"] == "BSD License"
开发者ID:alex,项目名称:warehouse,代码行数:13,代码来源:test_views.py


示例9: test_normalizing_version_redirects

    def test_normalizing_version_redirects(self, db_request):
        project = ProjectFactory.create()
        release = ReleaseFactory.create(project=project, version="3.0")

        db_request.matchdict = {"name": project.name, "version": "3.0.0.0.0"}
        db_request.current_route_path = pretend.call_recorder(
            lambda **kw: "/project/the-redirect/3.0/"
        )

        resp = views.release_detail(release, db_request)

        assert isinstance(resp, HTTPMovedPermanently)
        assert resp.headers["Location"] == "/project/the-redirect/3.0/"
        assert db_request.current_route_path.calls == [
            pretend.call(name=release.project.name, version=release.version),
        ]
开发者ID:ewdurbin,项目名称:warehouse,代码行数:16,代码来源:test_views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sessions.Session类代码示例发布时间:2022-05-26
下一篇:
Python views.project_detail函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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