fix test
This commit is contained in:
parent
6af487368e
commit
ad1cf3af8c
|
@ -177,7 +177,10 @@ class User(db.Model, ModelMixin, UserMixin):
|
|||
if self.lifetime_or_active_subscription():
|
||||
return True
|
||||
|
||||
return self.trial_end and arrow.now() < self.trial_end
|
||||
if self.trial_end and arrow.now() < self.trial_end:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def can_create_new_alias(self) -> bool:
|
||||
if self.is_premium():
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
meo
|
||||
cat
|
||||
chat
|
||||
chat
|
||||
alo
|
||||
hey
|
||||
yeah
|
||||
yes
|
|
@ -32,6 +32,7 @@ def test_out_of_quota(flask_client):
|
|||
user = User.create(
|
||||
email="a@b.c", password="password", name="Test User", activated=True
|
||||
)
|
||||
user.trial_end = None
|
||||
db.session.commit()
|
||||
|
||||
# create api_key
|
||||
|
|
|
@ -28,17 +28,16 @@ def test_out_of_quota(flask_client):
|
|||
user = User.create(
|
||||
email="a@b.c", password="password", name="Test User", activated=True
|
||||
)
|
||||
user.trial_end = None
|
||||
db.session.commit()
|
||||
|
||||
# create api_key
|
||||
api_key = ApiKey.create(user.id, "for test")
|
||||
db.session.commit()
|
||||
|
||||
# create 3 random alias to run out of quota
|
||||
# create MAX_NB_EMAIL_FREE_PLAN random alias to run out of quota
|
||||
for _ in range(MAX_NB_EMAIL_FREE_PLAN):
|
||||
GenEmail.create_new(user.id, prefix="test1")
|
||||
GenEmail.create_new(user.id, prefix="test2")
|
||||
GenEmail.create_new(user.id, prefix="test3")
|
||||
|
||||
r = flask_client.post(
|
||||
url_for("api.new_random_alias", hostname="www.test.com"),
|
||||
|
|
|
@ -4,7 +4,7 @@ from app.extensions import db
|
|||
from app.models import User, ApiKey, AliasUsedOn, GenEmail
|
||||
|
||||
|
||||
def test_success(flask_client):
|
||||
def test_user_in_trial(flask_client):
|
||||
user = User.create(
|
||||
email="a@b.c", password="password", name="Test User", activated=True
|
||||
)
|
||||
|
@ -19,7 +19,7 @@ def test_success(flask_client):
|
|||
)
|
||||
|
||||
assert r.status_code == 200
|
||||
assert r.json == {"is_premium": False, "name": "Test User"}
|
||||
assert r.json == {"is_premium": True, "name": "Test User"}
|
||||
|
||||
|
||||
def test_wrong_api_key(flask_client):
|
||||
|
|
|
@ -28,10 +28,16 @@ def test_profile_picture_url(flask_client):
|
|||
assert user.profile_picture_url() == "http://sl.test/static/default-avatar.png"
|
||||
|
||||
|
||||
def test_suggested_emails_for_user_who_cannot_create_new_email(flask_client):
|
||||
def test_suggested_emails_for_user_who_cannot_create_new_alias(flask_client):
|
||||
# make sure user is not in trial
|
||||
user = User.create(
|
||||
email="a@b.c", password="password", name="Test User", activated=True
|
||||
email="a@b.c",
|
||||
password="password",
|
||||
name="Test User",
|
||||
activated=True,
|
||||
trial_end=None,
|
||||
)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
# make sure user runs out of quota to create new email
|
||||
|
|
Loading…
Reference in New Issue