本文整理汇总了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
示例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"
示例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"
示例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")
]
示例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,
},
}
示例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"
示例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
}
示例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"
示例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),
]