Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Dec 22, 2022
2 parents 17ffedd + 7740e32 commit 638483c
Show file tree
Hide file tree
Showing 84 changed files with 705 additions and 562 deletions.
4 changes: 2 additions & 2 deletions bin/depchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

if extra_in_left:
for dep in sorted(extra_in_left):
print("- {}".format(dep))
print(f"- {dep}")

if extra_in_right:
for dep in sorted(extra_in_right):
print("+ {}".format(dep))
print(f"+ {dep}")

if extra_in_left or extra_in_right:
sys.exit(1)
1 change: 1 addition & 0 deletions bin/lint
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export LANG="${ENCODING:-en_US.UTF-8}"
set -x

# Actually run our tests.
find . -name '*.py' -exec python -m pyupgrade --py311-plus {} +
python -m flake8 .
python -m black --check *.py warehouse/ tests/
python -m isort --check *.py warehouse/ tests/
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 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
Expand Down
1 change: 0 additions & 1 deletion requirements/docs.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ furo
Sphinx
sphinxcontrib-httpdomain
myst-parser
docutils<0.19
# Until resolved https://github.com/googleapis/python-bigquery/issues/1435
packaging<22.0
7 changes: 3 additions & 4 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ charset-normalizer==2.1.1 \
--hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 \
--hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f
# via requests
docutils==0.18.1 \
--hash=sha256:23010f129180089fbcd3bc08cfefccb3b890b0050e1ca00c867036e9d161b98c \
--hash=sha256:679987caf361a7539d76e584cbeddc311e3aee937877c87346f31debc63e9d06
docutils==0.19 \
--hash=sha256:33995a6753c30b7f577febfc2c50411fec6aac7f7ffeb7c4cfe5991072dcf9e6 \
--hash=sha256:5e1de4d849fee02c63b040a4a3fd567f4ab104defd8a5511fbbc24a8a017efbc
# via
# -r requirements/docs.in
# myst-parser
# sphinx
furo==2022.12.7 \
Expand Down
2 changes: 1 addition & 1 deletion requirements/lint.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ flake8
curlylint
pep8-naming
black==22.12.0
docutils<0.19
isort>=5
pyupgrade
mypy
celery-types
msgpack-types
Expand Down
37 changes: 21 additions & 16 deletions requirements/lint.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ curlylint==0.13.1 \
--hash=sha256:008b9d160f3920404ac12efb05c0a39e209cb972f9aafd956b79c5f4e2162752 \
--hash=sha256:9546ea82cdfc9292fd6fe49dca28587164bd315782a209c0a46e013d7f38d2fa
# via -r requirements/lint.in
doc8==0.11.2 \
--hash=sha256:9187da8c9f115254bbe34f74e2bbbdd3eaa1b9e92efd19ccac7461e347b5055c \
--hash=sha256:c35a231f88f15c204659154ed3d499fa4d402d7e63d41cba7b54cf5e646123ab
doc8==1.0.0 \
--hash=sha256:0c6c3104fa7f7bb2103589c0a8e272c105fdff3ddd1ef4808e51b2782185e9ab \
--hash=sha256:1e999a14fe415ea96d89d5053c790d01061f19b6737706b817d1579c2a07cc16
# via -r requirements/lint.in
docutils==0.18.1 \
--hash=sha256:23010f129180089fbcd3bc08cfefccb3b890b0050e1ca00c867036e9d161b98c \
--hash=sha256:679987caf361a7539d76e584cbeddc311e3aee937877c87346f31debc63e9d06
docutils==0.19 \
--hash=sha256:33995a6753c30b7f577febfc2c50411fec6aac7f7ffeb7c4cfe5991072dcf9e6 \
--hash=sha256:5e1de4d849fee02c63b040a4a3fd567f4ab104defd8a5511fbbc24a8a017efbc
# via
# -r requirements/lint.in
# doc8
# restructuredtext-lint
flake8==4.0.1 \
Expand Down Expand Up @@ -144,13 +143,28 @@ pygments==2.13.0 \
--hash=sha256:56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1 \
--hash=sha256:f643f331ab57ba3c9d89212ee4a2dabc6e94f117cf4eefde99a0574720d14c42
# via doc8
pyupgrade==3.3.1 \
--hash=sha256:3b93641963df022d605c78aeae4b5956a5296ea24701eafaef9c487527b77e60 \
--hash=sha256:f88bce38b0ba92c2a9a5063c8629e456e8d919b67d2d42c7ecab82ff196f9813
# via -r requirements/lint.in
restructuredtext-lint==1.4.0 \
--hash=sha256:1b235c0c922341ab6c530390892eb9e92f90b9b75046063e047cacfb0f050c45
# via doc8
setuptools==65.6.3 \
--hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \
--hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75
# via
# zope-event
# zope-interface
# zope-schema
stevedore==4.1.1 \
--hash=sha256:7f8aeb6e3f90f96832c301bff21a7eb5eefbe894c88c506483d355565d88cc1a \
--hash=sha256:aa6436565c069b2946fe4ebff07f5041e0c8bf18c7376dd29edf80cf7d524e4e
# via doc8
tokenize-rt==5.0.0 \
--hash=sha256:3160bc0c3e8491312d0485171dea861fc160a240f5f5766b72a1165408d10740 \
--hash=sha256:c67772c662c6b3dc65edf66808577968fb10badfc2042e3027196bed4daf9e5a
# via pyupgrade
toml==0.10.2 \
--hash=sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b \
--hash=sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f
Expand Down Expand Up @@ -290,12 +304,3 @@ zope-schema==6.2.1 \
--hash=sha256:843c6fce13886333f707246f135a832f4408555ca9650f07ed6e4d429302f349 \
--hash=sha256:e3b33c8bc8ba9d85a56713ab8f0a3c2615d54a8085f1e415ce0c8dfb5e540be6
# via mypy-zope

# The following packages are considered to be unsafe in a requirements file:
setuptools==65.6.3 \
--hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \
--hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75
# via
# zope-event
# zope-interface
# zope-schema
1 change: 0 additions & 1 deletion requirements/main.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ click
cryptography
datadog>=0.19.0
disposable-email-domains
docutils<0.19
elasticsearch>=7.0.0,<7.11.0
elasticsearch_dsl>=7.0.0,<8.0.0
first
Expand Down
13 changes: 6 additions & 7 deletions requirements/main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,10 @@ dnspython==2.2.1 \
--hash=sha256:0f7569a4a6ff151958b64304071d370daa3243d15941a7beedf0c9fe5105603e \
--hash=sha256:a851e51367fb93e9e1361732c1d60dab63eff98712e503ea7d92e6eccb109b4f
# via email-validator
docutils==0.18.1 \
--hash=sha256:23010f129180089fbcd3bc08cfefccb3b890b0050e1ca00c867036e9d161b98c \
--hash=sha256:679987caf361a7539d76e584cbeddc311e3aee937877c87346f31debc63e9d06
docutils==0.19 \
--hash=sha256:33995a6753c30b7f577febfc2c50411fec6aac7f7ffeb7c4cfe5991072dcf9e6 \
--hash=sha256:5e1de4d849fee02c63b040a4a3fd567f4ab104defd8a5511fbbc24a8a017efbc
# via
# -r requirements/main.in
# readme-renderer
elasticsearch==7.10.1 \
--hash=sha256:4ebd34fd223b31c99d9f3b6b6236d3ac18b3046191a37231e8235b06ae7db955 \
Expand Down Expand Up @@ -1374,9 +1373,9 @@ translationstring==1.4 \
--hash=sha256:5f4dc4d939573db851c8d840551e1a0fb27b946afe3b95aafc22577eed2d6262 \
--hash=sha256:bf947538d76e69ba12ab17283b10355a9ecfbc078e6123443f43f2107f6376f3
# via pyramid
trove-classifiers==2022.12.1 \
--hash=sha256:20ce6feeadd5793718b2106f0c832f821f29838aec792143e620b0a0a0a810b8 \
--hash=sha256:8eccd9c075038ef2ec73276e2422d0dbf4d632f9133f029632d0df35374caf77
trove-classifiers==2022.12.22 \
--hash=sha256:f0013fd4ce06cfae879a2580ab6acc3d51ec93ecb364d6c061b6c77b44dd72de \
--hash=sha256:fe0fe3f085987161aee2a5a853c7cc7cdf64515c5965d57ad968fdd8cc3b0362
# via -r requirements/main.in
typeguard==2.13.3 \
--hash=sha256:00edaa8da3a133674796cf5ea87d9f4b4c367d77476e185e80251cc13dfbb8c4 \
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def pytest_collection_modifyitems(items):
elif module_root_dir.startswith("unit"):
item.add_marker(pytest.mark.unit)
else:
raise RuntimeError("Unknown test type (filename = {0})".format(module_path))
raise RuntimeError(f"Unknown test type (filename = {module_path})")


@contextmanager
Expand Down Expand Up @@ -220,7 +220,7 @@ def database(request):
def drop_database():
janitor.drop()

return "postgresql://{}@{}:{}/{}".format(pg_user, pg_host, pg_port, pg_db)
return f"postgresql://{pg_user}@{pg_host}:{pg_port}/{pg_db}"


class MockManifestCacheBuster(ManifestCacheBuster):
Expand Down
68 changes: 68 additions & 0 deletions tests/frontend/change_role_controller_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* 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.
*/

/* global expect, beforeEach, describe, it */

import { Application } from "@hotwired/stimulus";
import ChangeRoleController from "../../warehouse/static/js/warehouse/controllers/change_role_controller";

const roleContent = `
<div data-controller="change-role" data-change-role-current-value="Maintainer">
<form class="table__change-role" method="POST" action="/manage/project/pytest-socket/collaboration/change/">
<select id="role-for-deadbeef" class="table__change-field" name="role_name" data-action="change-role#change" autocomplete="off">
<option value="Maintainer" selected="">
Maintainer
</option>
<option value="Owner">
Owner
</option>
</select>
<button class="button button--primary table__change-button" title="Save role" data-change-role-target="saveButton" style="visibility: hidden;">
Save
</button>
</form>
</div>
`;

describe("ChangeRoleController", () => {
beforeEach(() => {
document.body.innerHTML = roleContent;
const application = Application.start();
application.register("change-role", ChangeRoleController);
});

describe("initial state", () => {
it("hides the button if the role is the same as the current role", () => {
const button = document.querySelector(".table__change-button");
expect(button.style.visibility).toEqual("hidden");
});
});

describe("change selection", () => {
it("shows the button and then hides it if changed back", () => {
const select = document.querySelector(".table__change-field");

select.value = "Owner";
select.dispatchEvent(new Event("change"));

let button = document.querySelector(".table__change-button");
expect(button.style.visibility).toEqual("visible");

select.value = "Maintainer";
select.dispatchEvent(new Event("change"));

button = document.querySelector(".table__change-button");
expect(button.style.visibility).toEqual("hidden");
});
});
});
2 changes: 1 addition & 1 deletion tests/functional/legacy_api/test_removed.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@pytest.mark.parametrize("action", ["submit", "submit_pkg_info"])
def test_removed_upload_apis(webtest, action):
resp = webtest.post("/legacy/?:action={}".format(action), status=410)
resp = webtest.post(f"/legacy/?:action={action}", status=410)
assert resp.status == (
"410 Project pre-registration is no longer required or supported, "
"upload your files instead."
Expand Down
13 changes: 9 additions & 4 deletions tests/unit/admin/views/test_includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@

from warehouse.admin.views import includes

from ....common.db.packaging import ProjectFactory

def test_administer_project_include_returns_project():
project = pretend.stub()
assert includes.administer_project_include(project, pretend.stub()) == {
"project": project

def test_administer_project_include_returns_project(db_request):
project = ProjectFactory.create()
db_request.matchdict = {"project_name": project.name}
assert includes.administer_project_include(db_request) == {
"project": project,
"prohibited": None,
"project_name": project.name,
}


Expand Down
24 changes: 12 additions & 12 deletions tests/unit/admin/views/test_journals.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ def test_query_basic(self, db_request):
)
[JournalEntryFactory.create(name=project1.normalized_name) for _ in range(30)]

db_request.GET["q"] = "{}".format(project0.name)
db_request.GET["q"] = f"{project0.name}"
result = views.journals_list(db_request)

assert result == {
"journals": journals0[:25],
"query": "{}".format(project0.name),
"query": f"{project0.name}",
}

def test_query_term_project(self, db_request):
Expand All @@ -83,12 +83,12 @@ def test_query_term_project(self, db_request):
)
[JournalEntryFactory.create(name=project1.normalized_name) for _ in range(30)]

db_request.GET["q"] = "project:{}".format(project0.name)
db_request.GET["q"] = f"project:{project0.name}"
result = views.journals_list(db_request)

assert result == {
"journals": journals0[:25],
"query": "project:{}".format(project0.name),
"query": f"project:{project0.name}",
}

def test_query_term_user(self, db_request):
Expand All @@ -101,23 +101,23 @@ def test_query_term_user(self, db_request):
)
[JournalEntryFactory.create(submitted_by=user1) for _ in range(30)]

db_request.GET["q"] = "user:{}".format(user0.username)
db_request.GET["q"] = f"user:{user0.username}"
result = views.journals_list(db_request)

assert result == {
"journals": journals0[:25],
"query": "user:{}".format(user0.username),
"query": f"user:{user0.username}",
}

def test_query_term_version(self, db_request):
journals = [JournalEntryFactory.create() for _ in range(10)]

db_request.GET["q"] = "version:{}".format(journals[0].version)
db_request.GET["q"] = f"version:{journals[0].version}"
result = views.journals_list(db_request)

assert result == {
"journals": [journals[0]],
"query": "version:{}".format(journals[0].version),
"query": f"version:{journals[0].version}",
}

def test_query_term_ip(self, db_request):
Expand All @@ -134,12 +134,12 @@ def test_query_term_ip(self, db_request):
reverse=True,
)

db_request.GET["q"] = "ip:{}".format(ipv4)
db_request.GET["q"] = f"ip:{ipv4}"
result = views.journals_list(db_request)

assert result == {"journals": journals0, "query": "ip:{}".format(ipv4)}
assert result == {"journals": journals0, "query": f"ip:{ipv4}"}

db_request.GET["q"] = "ip:{}".format(ipv6)
db_request.GET["q"] = f"ip:{ipv6}"
result = views.journals_list(db_request)

assert result == {"journals": journals1, "query": "ip:{}".format(ipv6)}
assert result == {"journals": journals1, "query": f"ip:{ipv6}"}

0 comments on commit 638483c

Please sign in to comment.