Fix exact email grants and clarify cloud and wind labels

This commit is contained in:
2569718930@qq.com
2026-04-07 10:17:17 +08:00
parent eab6ec7cff
commit 22621f5d9c
5 changed files with 78 additions and 12 deletions
+30
View File
@@ -0,0 +1,30 @@
from scripts.grant_subscription_by_email import _select_exact_user_id
from src.payments.contract_checkout import PaymentCheckoutError
def test_select_exact_user_id_prefers_exact_email_match():
payload = {
"users": [
{"id": "wrong-user", "email": "louischanre+alias@gmail.com"},
{"id": "right-user", "email": "louischanre@gmail.com"},
]
}
result = _select_exact_user_id(payload, "louischanre@gmail.com")
assert result == "right-user"
def test_select_exact_user_id_raises_when_exact_email_missing():
payload = {
"users": [
{"id": "wrong-user", "email": "louischanre+alias@gmail.com"},
]
}
try:
_select_exact_user_id(payload, "louischanre@gmail.com")
except PaymentCheckoutError as exc:
assert exc.status_code == 404
else:
raise AssertionError("expected PaymentCheckoutError")