Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/functional/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_templates_for_empty_titles():
for dir_, _, files in os.walk(dir_name):
if (
dir_.find("/includes") > -1
or dir_.find("/api") > -1
or dir_.find("/legacy") > -1
or dir_.find("/email/") > -1
):
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from pyramid.httpexceptions import HTTPMovedPermanently
from pyramid.testing import DummyRequest

from warehouse.legacy.api import simple
from warehouse.api import simple

from ....common.db.accounts import UserFactory
from ....common.db.packaging import (
from ...common.db.accounts import UserFactory
from ...common.db.packaging import (
FileFactory,
JournalEntryFactory,
ProjectFactory,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/packaging/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_render_simple_detail(db_request, monkeypatch, jinja):
fakeblake2b = pretend.call_recorder(lambda *a, **kw: fake_hasher)
monkeypatch.setattr(hashlib, "blake2b", fakeblake2b)

template = jinja.get_template("templates/legacy/api/simple/detail.html")
template = jinja.get_template("templates/api/simple/detail.html")
expected_content = template.render(
**_simple_detail(project, db_request), request=db_request
).encode("utf-8")
Expand Down Expand Up @@ -88,7 +88,7 @@ def __exit__(self, type, value, traceback):

monkeypatch.setattr(tempfile, "NamedTemporaryFile", FakeNamedTemporaryFile)

template = jinja.get_template("templates/legacy/api/simple/detail.html")
template = jinja.get_template("templates/api/simple/detail.html")
expected_content = template.render(
**_simple_detail(project, db_request), request=db_request
).encode("utf-8")
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,9 @@ def add_policy(name, filename):
"/_/vulnerabilities/osv/report",
domain=warehouse,
),
pretend.call("legacy.api.simple.index", "/simple/", domain=warehouse),
pretend.call("api.simple.index", "/simple/", domain=warehouse),
pretend.call(
"legacy.api.simple.detail",
"api.simple.detail",
"/simple/{name}/",
factory="warehouse.packaging.models:ProjectFactory",
traverse="/{name}/",
Expand Down
11 changes: 11 additions & 0 deletions warehouse/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
8 changes: 4 additions & 4 deletions warehouse/legacy/api/simple.py → warehouse/api/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def _select_content_type(request: Request) -> str:


@view_config(
route_name="legacy.api.simple.index",
renderer="legacy/api/simple/index.html",
route_name="api.simple.index",
renderer="api/simple/index.html",
decorator=[
add_vary("Accept"),
cache_control(10 * 60), # 10 minutes
Expand All @@ -79,9 +79,9 @@ def simple_index(request):


@view_config(
route_name="legacy.api.simple.detail",
route_name="api.simple.detail",
context=Project,
renderer="legacy/api/simple/detail.html",
renderer="api/simple/detail.html",
decorator=[
add_vary("Accept"),
cache_control(10 * 60), # 10 minutes
Expand Down
2 changes: 1 addition & 1 deletion warehouse/packaging/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def render_simple_detail(project, request, store=False):
context = _simple_detail(project, request)

env = request.registry.queryUtility(IJinja2Environment, name=".jinja2")
template = env.get_template("templates/legacy/api/simple/detail.html")
template = env.get_template("templates/api/simple/detail.html")
content = template.render(**context, request=request)

content_hasher = hashlib.blake2b(digest_size=256 // 8)
Expand Down
7 changes: 4 additions & 3 deletions warehouse/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,17 +427,18 @@ def includeme(config):
domain=warehouse,
)

# Legacy URLs
config.add_route("legacy.api.simple.index", "/simple/", domain=warehouse)
# API URLs
config.add_route("api.simple.index", "/simple/", domain=warehouse)
config.add_route(
"legacy.api.simple.detail",
"api.simple.detail",
"/simple/{name}/",
factory="warehouse.packaging.models:ProjectFactory",
traverse="/{name}/",
read_only=True,
domain=warehouse,
)

# Legacy URLs
config.add_route(
"legacy.api.json.project",
"/pypi/{name}/json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</head>
<body>
{% for project in projects -%}
<a href="{{ request.route_path('legacy.api.simple.detail', name=project.name|canonicalize_name) }}">{{ project.name }}</a>
<a href="{{ request.route_path('api.simple.detail', name=project.name|canonicalize_name) }}">{{ project.name }}</a>
{% endfor -%}
</body>
</html>