test_custom_domain.py 1012 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. from flask import url_for
  2. from app.extensions import db
  3. from tests.utils import login
  4. def test_add_domain_success(flask_client):
  5. user = login(flask_client)
  6. user.lifetime = True
  7. db.session.commit()
  8. r = flask_client.post(
  9. url_for("dashboard.custom_domain"),
  10. data={"form-name": "create", "domain": "ab.cd"},
  11. follow_redirects=True,
  12. )
  13. assert r.status_code == 200
  14. assert b"New domain ab.cd is created" in r.data
  15. def test_add_domain_same_as_user_email(flask_client):
  16. """cannot add domain if user personal email uses this domain"""
  17. user = login(flask_client)
  18. user.lifetime = True
  19. db.session.commit()
  20. r = flask_client.post(
  21. url_for("dashboard.custom_domain"),
  22. data={"form-name": "create", "domain": "b.c"}, # user email is a@b.c
  23. follow_redirects=True,
  24. )
  25. assert r.status_code == 200
  26. assert (
  27. b"You cannot add a domain that you are currently using for your personal email"
  28. in r.data
  29. )