Skip to content

Add some releases to the Simple API functional test #16556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from http import HTTPStatus

from ...common.db.packaging import ProjectFactory
from ...common.db.packaging import ProjectFactory, ReleaseFactory


def test_simple_api_html(webtest):
Expand All @@ -24,6 +24,8 @@ def test_simple_api_html(webtest):

def test_simple_api_detail(webtest):
project = ProjectFactory.create()
ReleaseFactory.create(version="1.0.0", project=project)
ReleaseFactory.create(version="2.0.0", project=project)

resp = webtest.get(f"/simple/{project.normalized_name}/", status=HTTPStatus.OK)

Expand Down
11 changes: 11 additions & 0 deletions tests/functional/forklift/__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 @@ -13,6 +13,24 @@
import pytest


def test_incorrect_post_redirect(webtest):
"""
Per issue #8104, we should issue an HTTP-308 for a POST
in /legacy and point the user to the correct endpoint,
/legacy/

See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308
"""
resp = webtest.post("/legacy", status=308)
assert resp.status == (
"308 An upload was attempted to /legacy but the expected upload URL is "
"/legacy/ (with a trailing slash)"
)

assert "location" in resp.headers
assert resp.headers["location"] == "http://localhost/legacy/"


@pytest.mark.parametrize("action", ["submit", "submit_pkg_info"])
def test_removed_upload_apis(webtest, action):
resp = webtest.post(f"/legacy/?:action={action}", status=410)
Expand All @@ -28,8 +46,3 @@ def test_remove_doc_upload(webtest):
"410 Uploading documentation is no longer supported, we recommend "
"using https://readthedocs.org/."
)


def test_doap(webtest):
resp = webtest.get("/pypi?:action=doap&name=foo&version=1.0", status=410)
assert resp.status == "410 DOAP is no longer supported."
11 changes: 11 additions & 0 deletions tests/functional/legacy/__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.
11 changes: 11 additions & 0 deletions tests/functional/legacy/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.
16 changes: 16 additions & 0 deletions tests/functional/legacy/api/test_pypi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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.


def test_doap(webtest):
resp = webtest.get("/pypi?:action=doap&name=foo&version=1.0", status=410)
assert resp.status == "410 DOAP is no longer supported."
29 changes: 0 additions & 29 deletions tests/functional/legacy_api/test_basic.py

This file was deleted.