本文整理汇总了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;未经允许,请勿转载。 |
请发表评论