This commit is contained in:
Son NK 2019-12-08 17:01:24 +01:00
parent 8e9aef1199
commit 6ddb8ee5ab
4 changed files with 13 additions and 10 deletions

View File

@ -21,6 +21,7 @@ from app.config import (
SHA1, SHA1,
PADDLE_MONTHLY_PRODUCT_ID, PADDLE_MONTHLY_PRODUCT_ID,
RESET_DB, RESET_DB,
EMAIL_DOMAIN,
) )
from app.dashboard.base import dashboard_bp from app.dashboard.base import dashboard_bp
from app.developer.base import developer_bp from app.developer.base import developer_bp
@ -118,9 +119,9 @@ def fake_data():
api_key = ApiKey.create(user_id=user.id, name="Chrome") api_key = ApiKey.create(user_id=user.id, name="Chrome")
api_key.code = "code" api_key.code = "code"
GenEmail.create_new_gen_email(user_id=user.id) GenEmail.create_custom_alias(user.id, "e1@")
GenEmail.create_custom_alias(user.id, "e2@")
GenEmail.create_new_gen_email(user_id=user.id, custom=True) GenEmail.create_custom_alias(user.id, "e3@")
# Create a client # Create a client
client1 = Client.create_new(name="Demo", user_id=user.id) client1 = Client.create_new(name="Demo", user_id=user.id)

View File

@ -41,7 +41,7 @@ def test_different_scenarios(flask_client):
assert r.json["custom"]["suggestion"] == "test" assert r.json["custom"]["suggestion"] == "test"
# <<< with recommendation >>> # <<< with recommendation >>>
alias = GenEmail.create_new_gen_email(user.id) alias = GenEmail.create_custom_alias(user.id, prefix="test")
db.session.commit() db.session.commit()
AliasUsedOn.create(gen_email_id=alias.id, hostname="www.test.com") AliasUsedOn.create(gen_email_id=alias.id, hostname="www.test.com")
db.session.commit() db.session.commit()

View File

@ -36,9 +36,9 @@ def test_out_of_quota(flask_client):
db.session.commit() db.session.commit()
# create 3 custom alias to run out of quota # create 3 custom alias to run out of quota
GenEmail.create_new_gen_email(user.id, custom=True) GenEmail.create_custom_alias(user.id, prefix="test")
GenEmail.create_new_gen_email(user.id, custom=True) GenEmail.create_custom_alias(user.id, prefix="test")
GenEmail.create_new_gen_email(user.id, custom=True) GenEmail.create_custom_alias(user.id, prefix="test")
r = flask_client.post( r = flask_client.post(
url_for("api.new_custom_alias", hostname="www.test.com"), url_for("api.new_custom_alias", hostname="www.test.com"),

View File

@ -25,10 +25,12 @@ def test_suggested_emails_for_user_who_can_create_new_random_alias(flask_client)
) )
db.session.commit() db.session.commit()
suggested_email, other_emails = user.suggested_emails() suggested_email, other_emails = user.suggested_emails(website_name="test")
assert suggested_email assert suggested_email
assert len(other_emails) == 1 assert len(other_emails) == 1
db.session.rollback()
# the suggested email is new and not exist in GenEmail # the suggested email is new and not exist in GenEmail
assert GenEmail.get_by(email=suggested_email) is None assert GenEmail.get_by(email=suggested_email) is None
@ -44,10 +46,10 @@ def test_suggested_emails_for_user_who_cannot_create_new_email(flask_client):
# make sure user runs out of quota to create new email # make sure user runs out of quota to create new email
for i in range(MAX_NB_EMAIL_FREE_PLAN): for i in range(MAX_NB_EMAIL_FREE_PLAN):
GenEmail.create_new_gen_email(user_id=user.id) GenEmail.create_custom_alias(user_id=user.id, prefix="test")
db.session.commit() db.session.commit()
suggested_email, other_emails = user.suggested_emails() suggested_email, other_emails = user.suggested_emails(website_name="test")
# the suggested email is chosen from existing GenEmail # the suggested email is chosen from existing GenEmail
assert GenEmail.get_by(email=suggested_email) assert GenEmail.get_by(email=suggested_email)