refactor: replace decpinfo with colibre in test client identifiers
Update test fixtures and client references to use colibre branding instead of the legacy decpinfo naming convention. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -252,7 +252,7 @@ def main() -> None:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--token",
|
"--token",
|
||||||
default=None,
|
default=None,
|
||||||
help="Token Bearer colibre (format decpinfo_xxx)",
|
help="Token Bearer colibre (format colibre_xxx)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--runs",
|
"--runs",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ def test_bearer_without_value_returns_401(temp_db):
|
|||||||
def test_invalid_token_returns_401(temp_db):
|
def test_invalid_token_returns_401(temp_db):
|
||||||
app = _make_app()
|
app = _make_app()
|
||||||
resp = app.test_client().get(
|
resp = app.test_client().get(
|
||||||
"/protected", headers={"Authorization": "Bearer decpinfo_unknown"}
|
"/protected", headers={"Authorization": "Bearer colibre_unknown"}
|
||||||
)
|
)
|
||||||
assert resp.status_code == 401
|
assert resp.status_code == 401
|
||||||
assert resp.get_json()["message"] == "invalid_token"
|
assert resp.get_json()["message"] == "invalid_token"
|
||||||
|
|||||||
@@ -4,22 +4,22 @@ from src.subscriptions import client
|
|||||||
|
|
||||||
|
|
||||||
def test_auth_and_base_url_used(fake_httpx):
|
def test_auth_and_base_url_used(fake_httpx):
|
||||||
fake_httpx["queue"].append(fake_httpx["Response"](200, {"handle": "decpinfo-1"}))
|
fake_httpx["queue"].append(fake_httpx["Response"](200, {"handle": "colibre-1"}))
|
||||||
client.get_customer("decpinfo-1")
|
client.get_customer("colibre-1")
|
||||||
call = fake_httpx["calls"][0]
|
call = fake_httpx["calls"][0]
|
||||||
assert call["url"] == "https://api.test/v1/customer/decpinfo-1"
|
assert call["url"] == "https://api.test/v1/customer/colibre-1"
|
||||||
assert call["auth"] == ("priv_test", "")
|
assert call["auth"] == ("priv_test", "")
|
||||||
|
|
||||||
|
|
||||||
def test_get_customer(fake_httpx):
|
def test_get_customer(fake_httpx):
|
||||||
fake_httpx["queue"].append(fake_httpx["Response"](200, {"handle": "decpinfo-1"}))
|
fake_httpx["queue"].append(fake_httpx["Response"](200, {"handle": "colibre-1"}))
|
||||||
result = client.get_customer("decpinfo-1")
|
result = client.get_customer("colibre-1")
|
||||||
assert result == {"handle": "decpinfo-1"}
|
assert result == {"handle": "colibre-1"}
|
||||||
|
|
||||||
|
|
||||||
def test_update_customer(fake_httpx):
|
def test_update_customer(fake_httpx):
|
||||||
fake_httpx["queue"].append(fake_httpx["Response"](200, {"handle": "decpinfo-1"}))
|
fake_httpx["queue"].append(fake_httpx["Response"](200, {"handle": "colibre-1"}))
|
||||||
client.update_customer("decpinfo-1", {"email": "a@b.fr"})
|
client.update_customer("colibre-1", {"email": "a@b.fr"})
|
||||||
call = fake_httpx["calls"][0]
|
call = fake_httpx["calls"][0]
|
||||||
assert call["method"] == "PUT"
|
assert call["method"] == "PUT"
|
||||||
assert call["json"] == {"email": "a@b.fr"}
|
assert call["json"] == {"email": "a@b.fr"}
|
||||||
@@ -40,12 +40,12 @@ def test_create_subscription_session_with_customer_handle(fake_httpx):
|
|||||||
"plan_simple",
|
"plan_simple",
|
||||||
"https://app/ok",
|
"https://app/ok",
|
||||||
"https://app/ko",
|
"https://app/ko",
|
||||||
customer_handle="decpinfo-1",
|
customer_handle="colibre-1",
|
||||||
)
|
)
|
||||||
assert url == "https://checkout.reepay.com/#/sub-1"
|
assert url == "https://checkout.reepay.com/#/sub-1"
|
||||||
body = fake_httpx["calls"][0]["json"]
|
body = fake_httpx["calls"][0]["json"]
|
||||||
assert body["plan"] == "plan_simple"
|
assert body["plan"] == "plan_simple"
|
||||||
assert body["customer"] == "decpinfo-1"
|
assert body["customer"] == "colibre-1"
|
||||||
assert body["signup_method"] == "link"
|
assert body["signup_method"] == "link"
|
||||||
assert "prepare_subscription" not in body
|
assert "prepare_subscription" not in body
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ def test_create_subscription_session_no_trial(fake_httpx):
|
|||||||
"https://app/ok",
|
"https://app/ok",
|
||||||
"https://app/ko",
|
"https://app/ko",
|
||||||
no_trial=True,
|
no_trial=True,
|
||||||
customer_handle="decpinfo-1",
|
customer_handle="colibre-1",
|
||||||
)
|
)
|
||||||
assert fake_httpx["calls"][0]["json"]["no_trial"] is True
|
assert fake_httpx["calls"][0]["json"]["no_trial"] is True
|
||||||
|
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ def test_subscribe_redirects_to_hosted_url(logged_in_client, monkeypatch):
|
|||||||
def test_subscribe_disables_trial_after_first_use(logged_in_client, monkeypatch):
|
def test_subscribe_disables_trial_after_first_use(logged_in_client, monkeypatch):
|
||||||
client, uid = logged_in_client
|
client, uid = logged_in_client
|
||||||
# L'utilisateur a déjà consommé un essai par le passé (abonnement maintenant expiré).
|
# L'utilisateur a déjà consommé un essai par le passé (abonnement maintenant expiré).
|
||||||
db.create_pending(uid, "decpinfo-%d" % uid, "simple")
|
db.create_pending(uid, "colibre-%d" % uid, "simple")
|
||||||
db.update_from_webhook(
|
db.update_from_webhook(
|
||||||
"decpinfo-%d" % uid, "sub_42", "trial", "2099-01-01T00:00:00+00:00"
|
"colibre-%d" % uid, "sub_42", "trial", "2099-01-01T00:00:00+00:00"
|
||||||
)
|
)
|
||||||
# L'essai est terminé : abonnement expiré, trial_used reste à 1.
|
# L'essai est terminé : abonnement expiré, trial_used reste à 1.
|
||||||
db.update_from_webhook(
|
db.update_from_webhook(
|
||||||
"decpinfo-%d" % uid, "sub_42", "expired", "2020-01-01T00:00:00+00:00"
|
"colibre-%d" % uid, "sub_42", "expired", "2020-01-01T00:00:00+00:00"
|
||||||
)
|
)
|
||||||
captured = {}
|
captured = {}
|
||||||
monkeypatch.setattr(frisbii_client, "update_customer", lambda h, d: {})
|
monkeypatch.setattr(frisbii_client, "update_customer", lambda h, d: {})
|
||||||
@@ -83,9 +83,9 @@ def test_subscribe_requires_login(sub_app):
|
|||||||
|
|
||||||
def test_cancel_calls_api_and_marks_cancelled(logged_in_client, monkeypatch):
|
def test_cancel_calls_api_and_marks_cancelled(logged_in_client, monkeypatch):
|
||||||
client, uid = logged_in_client
|
client, uid = logged_in_client
|
||||||
db.create_pending(uid, "decpinfo-%d" % uid, "simple")
|
db.create_pending(uid, "colibre-%d" % uid, "simple")
|
||||||
db.update_from_webhook(
|
db.update_from_webhook(
|
||||||
"decpinfo-%d" % uid, "sub_42", "active", "2099-01-01T00:00:00+00:00"
|
"colibre-%d" % uid, "sub_42", "active", "2099-01-01T00:00:00+00:00"
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
frisbii_client,
|
frisbii_client,
|
||||||
@@ -112,7 +112,7 @@ def test_webhook_updates_subscription(sub_app, monkeypatch):
|
|||||||
|
|
||||||
auth_db.init_schema()
|
auth_db.init_schema()
|
||||||
uid = auth_db.create_user("wh@ex.fr", "hash")
|
uid = auth_db.create_user("wh@ex.fr", "hash")
|
||||||
db.create_pending(uid, "decpinfo-%d" % uid, "simple")
|
db.create_pending(uid, "colibre-%d" % uid, "simple")
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
frisbii_client,
|
frisbii_client,
|
||||||
"get_subscription",
|
"get_subscription",
|
||||||
@@ -122,7 +122,7 @@ def test_webhook_updates_subscription(sub_app, monkeypatch):
|
|||||||
"id": "evt_1",
|
"id": "evt_1",
|
||||||
"timestamp": "2026-06-25T10:00:00Z",
|
"timestamp": "2026-06-25T10:00:00Z",
|
||||||
"event_type": "subscription_created",
|
"event_type": "subscription_created",
|
||||||
"customer": "decpinfo-%d" % uid,
|
"customer": "colibre-%d" % uid,
|
||||||
"subscription": "sub_42",
|
"subscription": "sub_42",
|
||||||
}
|
}
|
||||||
payload["signature"] = _sign("s3cr3t", payload["timestamp"], payload["id"])
|
payload["signature"] = _sign("s3cr3t", payload["timestamp"], payload["id"])
|
||||||
@@ -136,9 +136,9 @@ def test_webhook_updates_subscription(sub_app, monkeypatch):
|
|||||||
def test_subscribe_skips_if_already_active(logged_in_client, monkeypatch):
|
def test_subscribe_skips_if_already_active(logged_in_client, monkeypatch):
|
||||||
"""Fix 1 : un abonné actif ne doit pas voir son statut remis à 'pending'."""
|
"""Fix 1 : un abonné actif ne doit pas voir son statut remis à 'pending'."""
|
||||||
client, uid = logged_in_client
|
client, uid = logged_in_client
|
||||||
db.create_pending(uid, "decpinfo-%d" % uid, "simple")
|
db.create_pending(uid, "colibre-%d" % uid, "simple")
|
||||||
db.update_from_webhook(
|
db.update_from_webhook(
|
||||||
"decpinfo-%d" % uid, "sub_42", "active", "2099-01-01T00:00:00+00:00"
|
"colibre-%d" % uid, "sub_42", "active", "2099-01-01T00:00:00+00:00"
|
||||||
)
|
)
|
||||||
called = []
|
called = []
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
@@ -156,9 +156,9 @@ def test_subscribe_skips_if_already_active(logged_in_client, monkeypatch):
|
|||||||
def test_subscribe_skips_if_trial_active(logged_in_client, monkeypatch):
|
def test_subscribe_skips_if_trial_active(logged_in_client, monkeypatch):
|
||||||
"""Fix 1 : un abonné en période d'essai est protégé de la même façon."""
|
"""Fix 1 : un abonné en période d'essai est protégé de la même façon."""
|
||||||
client, uid = logged_in_client
|
client, uid = logged_in_client
|
||||||
db.create_pending(uid, "decpinfo-%d" % uid, "simple")
|
db.create_pending(uid, "colibre-%d" % uid, "simple")
|
||||||
db.update_from_webhook(
|
db.update_from_webhook(
|
||||||
"decpinfo-%d" % uid, "sub_42", "trial", "2099-01-01T00:00:00+00:00"
|
"colibre-%d" % uid, "sub_42", "trial", "2099-01-01T00:00:00+00:00"
|
||||||
)
|
)
|
||||||
resp = client.post("/subscriptions/subscribe", data={"plan": "simple"})
|
resp = client.post("/subscriptions/subscribe", data={"plan": "simple"})
|
||||||
assert resp.status_code == 302
|
assert resp.status_code == 302
|
||||||
|
|||||||
Reference in New Issue
Block a user