2022-04-15 23:37:19 +08:00
|
|
|
from app.db import Session
|
2021-11-02 22:20:33 +08:00
|
|
|
from app.models import (
|
|
|
|
Alias,
|
2021-11-02 22:30:18 +08:00
|
|
|
Contact,
|
2021-11-02 22:20:33 +08:00
|
|
|
)
|
|
|
|
from tests.utils import login
|
|
|
|
|
|
|
|
|
2021-11-02 22:30:18 +08:00
|
|
|
def test_disable_alias(flask_client):
|
2022-04-15 23:37:19 +08:00
|
|
|
user = login(flask_client)
|
|
|
|
alias = Alias.create_new_random(user)
|
|
|
|
Session.commit()
|
2021-11-02 22:20:33 +08:00
|
|
|
|
2021-11-02 22:30:18 +08:00
|
|
|
assert alias.enabled
|
2021-11-02 22:20:33 +08:00
|
|
|
flask_client.post(f"/dashboard/unsubscribe/{alias.id}")
|
|
|
|
assert not alias.enabled
|
2021-11-02 22:30:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
def test_block_contact(flask_client):
|
|
|
|
user = login(flask_client)
|
|
|
|
alias = Alias.first()
|
|
|
|
contact = Contact.create(
|
|
|
|
user_id=user.id,
|
|
|
|
alias_id=alias.id,
|
|
|
|
website_email="contact@example.com",
|
|
|
|
reply_email="re1@SL",
|
|
|
|
commit=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert not contact.block_forward
|
|
|
|
flask_client.post(f"/dashboard/block_contact/{contact.id}")
|
|
|
|
assert contact.block_forward
|
|
|
|
|
|
|
|
# make sure the page loads
|
|
|
|
flask_client.get(f"/dashboard/block_contact/{contact.id}")
|