app/tests/dashboard/test_custom_domain.py
Son 372466ab06 do not use flask-sqlalchemy
- add __tablename__ for all models
- use sa and orm instead of db
- rollback all changes in tests
- remove session in @app.teardown_appcontext
2021-10-12 14:36:47 +02:00

38 lines
1,003 B
Python

from flask import url_for
from app.db import Session
from tests.utils import login
def test_add_domain_success(flask_client):
user = login(flask_client)
user.lifetime = True
Session.commit()
r = flask_client.post(
url_for("dashboard.custom_domain"),
data={"form-name": "create", "domain": "ab.cd"},
follow_redirects=True,
)
assert r.status_code == 200
assert b"New domain ab.cd is created" in r.data
def test_add_domain_same_as_user_email(flask_client):
"""cannot add domain if user personal email uses this domain"""
user = login(flask_client)
user.lifetime = True
Session.commit()
r = flask_client.post(
url_for("dashboard.custom_domain"),
data={"form-name": "create", "domain": "b.c"}, # user email is a@b.c
follow_redirects=True,
)
assert r.status_code == 200
assert (
b"You cannot add a domain that you are currently using for your personal email"
in r.data
)