2022-06-20 11:36:16 +02:00
|
|
|
from app import config
|
|
|
|
from app.db import Session
|
|
|
|
from app.models import User, Job
|
2022-06-16 10:25:50 +02:00
|
|
|
from tests.utils import create_new_user, random_email
|
2020-10-15 16:45:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_available_sl_domains(flask_client):
|
2022-04-15 16:59:44 +02:00
|
|
|
user = create_new_user()
|
2020-10-15 16:45:08 +02:00
|
|
|
|
|
|
|
assert set(user.available_sl_domains()) == {"d1.test", "d2.test", "sl.local"}
|
2022-06-16 10:25:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_create_from_partner(flask_client):
|
|
|
|
user = User.create(email=random_email(), from_partner=True)
|
|
|
|
assert User.FLAG_CREATED_FROM_PARTNER == (
|
|
|
|
user.flags & User.FLAG_CREATED_FROM_PARTNER
|
|
|
|
)
|
|
|
|
assert user.notification is False
|
|
|
|
assert user.trial_end is None
|
2022-06-20 11:36:16 +02:00
|
|
|
job = Session.query(Job).order_by(Job.id.desc()).first()
|
|
|
|
assert job is not None
|
|
|
|
assert job.name == config.JOB_SEND_PROTON_WELCOME_1
|
|
|
|
assert job.payload.get("user_id") == user.id
|
2022-06-28 11:57:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_user_created_by_partner(flask_client):
|
|
|
|
user_from_partner = User.create(email=random_email(), from_partner=True)
|
|
|
|
assert user_from_partner.created_by_partner is True
|
|
|
|
|
|
|
|
regular_user = User.create(email=random_email())
|
|
|
|
assert regular_user.created_by_partner is False
|