|
|
@ -5,6 +5,7 @@ from flask_login.test_client import FlaskLoginClient
|
|
|
|
|
|
|
|
|
|
|
|
from htmx_contact import create_app
|
|
|
|
from htmx_contact import create_app
|
|
|
|
from htmx_contact.config import ContactSettings
|
|
|
|
from htmx_contact.config import ContactSettings
|
|
|
|
|
|
|
|
from htmx_contact.models import Contact
|
|
|
|
from htmx_contact.models import User
|
|
|
|
from htmx_contact.models import User
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -18,6 +19,36 @@ def test_user():
|
|
|
|
return User(id=1, primary_email="test", password="test", username="test")
|
|
|
|
return User(id=1, primary_email="test", password="test", username="test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
|
|
|
|
def test_contacts(test_user):
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
|
|
|
Contact(
|
|
|
|
|
|
|
|
id=1,
|
|
|
|
|
|
|
|
user_id=test_user.id,
|
|
|
|
|
|
|
|
first_name="Mark",
|
|
|
|
|
|
|
|
last_name="Zuckerberg",
|
|
|
|
|
|
|
|
email="zuck@facebook.com",
|
|
|
|
|
|
|
|
phone="555-777-1337",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Contact(
|
|
|
|
|
|
|
|
id=2,
|
|
|
|
|
|
|
|
user_id=test_user.id,
|
|
|
|
|
|
|
|
first_name="Shaan",
|
|
|
|
|
|
|
|
last_name="Puri",
|
|
|
|
|
|
|
|
email="shaan@twitter.com",
|
|
|
|
|
|
|
|
phone="666-777-1337",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Contact(
|
|
|
|
|
|
|
|
id=3,
|
|
|
|
|
|
|
|
user_id=test_user.id,
|
|
|
|
|
|
|
|
first_name="Sam",
|
|
|
|
|
|
|
|
last_name="Par",
|
|
|
|
|
|
|
|
email="sam@thesampar.com",
|
|
|
|
|
|
|
|
phone="587-343-1337",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
@pytest.fixture()
|
|
|
|
def app(test_config):
|
|
|
|
def app(test_config):
|
|
|
|
app = create_app(config=test_config)
|
|
|
|
app = create_app(config=test_config)
|
|
|
@ -25,6 +56,8 @@ def app(test_config):
|
|
|
|
app.config.update(
|
|
|
|
app.config.update(
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"TESTING": True,
|
|
|
|
"TESTING": True,
|
|
|
|
|
|
|
|
# disbale session protection or session "freshness" will cause failures.
|
|
|
|
|
|
|
|
"SESSION_PROTECTION": None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -42,7 +75,8 @@ def anynomous_client(app):
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
@pytest.fixture()
|
|
|
|
def client(app, test_user):
|
|
|
|
def client(app, test_user):
|
|
|
|
return app.test_client(user=test_user)
|
|
|
|
with app.test_client(user=test_user) as client:
|
|
|
|
|
|
|
|
yield client
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
@pytest.fixture()
|
|
|
|