fix(gtea): ruff format + check all gtea files and bridge.py
Clears cc-ci self-test lint failures: - ruff format: 9 files reformatted (all gtea test files + test_discovery.py) - ruff check --fix: bridge.py UP017 (datetime.UTC alias) + 6 gtea check errors - manifest.py B007: rename unused loop variable path → _path (no auto-fix available) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -16,10 +16,10 @@ import urllib.request
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner"))
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||
from ops import admin_creds # noqa: E402
|
||||
|
||||
import ssl
|
||||
|
||||
from ops import admin_creds # noqa: E402
|
||||
|
||||
_CTX = ssl.create_default_context()
|
||||
_CTX.check_hostname = False
|
||||
_CTX.verify_mode = ssl.CERT_NONE
|
||||
@ -68,7 +68,9 @@ def test_admin_api_user_org_token_lifecycle(live_app):
|
||||
|
||||
# 1. Create test user
|
||||
status, body = _api(
|
||||
live_app, "/admin/users", method="POST",
|
||||
live_app,
|
||||
"/admin/users",
|
||||
method="POST",
|
||||
body={
|
||||
"username": test_user,
|
||||
"email": f"{test_user}@ci.local",
|
||||
@ -77,7 +79,8 @@ def test_admin_api_user_org_token_lifecycle(live_app):
|
||||
"login_name": test_user,
|
||||
"source_id": 0,
|
||||
},
|
||||
user=adm_user, password=adm_pass,
|
||||
user=adm_user,
|
||||
password=adm_pass,
|
||||
)
|
||||
assert status == 201, f"user create HTTP {status}: {body}"
|
||||
assert body.get("login") == test_user, f"unexpected login: {body}"
|
||||
@ -85,9 +88,12 @@ def test_admin_api_user_org_token_lifecycle(live_app):
|
||||
try:
|
||||
# 2. Create org (as admin, add test user as member)
|
||||
status, body = _api(
|
||||
live_app, "/orgs", method="POST",
|
||||
live_app,
|
||||
"/orgs",
|
||||
method="POST",
|
||||
body={"username": test_org, "visibility": "public"},
|
||||
user=adm_user, password=adm_pass,
|
||||
user=adm_user,
|
||||
password=adm_pass,
|
||||
)
|
||||
assert status == 201, f"org create HTTP {status}: {body}"
|
||||
assert body.get("username") == test_org, f"unexpected org: {body}"
|
||||
@ -96,9 +102,12 @@ def test_admin_api_user_org_token_lifecycle(live_app):
|
||||
# 3. Create API token for test user (admin creates token on behalf of user).
|
||||
# Gitea 1.22+ requires explicit scopes; supply the minimum needed for steps 4-5.
|
||||
status, tok_body = _api(
|
||||
live_app, f"/users/{test_user}/tokens", method="POST",
|
||||
live_app,
|
||||
f"/users/{test_user}/tokens",
|
||||
method="POST",
|
||||
body={"name": token_name, "scopes": ["read:user", "read:organization"]},
|
||||
user=adm_user, password=adm_pass,
|
||||
user=adm_user,
|
||||
password=adm_pass,
|
||||
)
|
||||
assert status == 201, f"token create HTTP {status}: {tok_body}"
|
||||
token = tok_body.get("sha1")
|
||||
@ -116,8 +125,11 @@ def test_admin_api_user_org_token_lifecycle(live_app):
|
||||
|
||||
# 6. Delete the token
|
||||
status, _ = _api(
|
||||
live_app, f"/users/{test_user}/tokens/{token_name}", method="DELETE",
|
||||
user=adm_user, password=adm_pass,
|
||||
live_app,
|
||||
f"/users/{test_user}/tokens/{token_name}",
|
||||
method="DELETE",
|
||||
user=adm_user,
|
||||
password=adm_pass,
|
||||
)
|
||||
assert status in (204, 404), f"token delete HTTP {status}"
|
||||
|
||||
@ -127,5 +139,6 @@ def test_admin_api_user_org_token_lifecycle(live_app):
|
||||
|
||||
finally:
|
||||
# Delete test user (admin only)
|
||||
_api(live_app, f"/admin/users/{test_user}", method="DELETE",
|
||||
user=adm_user, password=adm_pass)
|
||||
_api(
|
||||
live_app, f"/admin/users/{test_user}", method="DELETE", user=adm_user, password=adm_pass
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user