This commit is contained in:
2023-05-10 11:00:05 +00:00
parent 2c82b03f8d
commit ce5124605a
15 changed files with 570 additions and 372 deletions

View File

@ -129,3 +129,12 @@ def test_change_name(flask_client):
assert r.json["name"] == "new name"
assert user.name == "new name"
def test_stats(flask_client):
login(flask_client)
r = flask_client.get("/api/stats")
assert r.status_code == 200
assert r.json == {"nb_alias": 1, "nb_block": 0, "nb_forward": 0, "nb_reply": 0}

View File

@ -0,0 +1,20 @@
from flask import url_for
from app.models import Coupon
from app.utils import random_string
from tests.utils import login
def test_use_coupon(flask_client):
user = login(flask_client)
code = random_string(10)
Coupon.create(code=code, nb_year=1, commit=True)
r = flask_client.post(
url_for("dashboard.coupon_route"),
data={"code": code},
)
assert r.status_code == 302
coupon = Coupon.get_by(code=code)
assert coupon.used
assert coupon.used_by_user_id == user.id