forked from JeffVandrewJr/patron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
36 lines (30 loc) · 793 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from app import create_app, db
from app.models import User
from tests.tconfig import Config
from datetime import datetime, timedelta
import pytest
@pytest.fixture(scope='module')
def new_user():
user = User(
username='test',
email='[email protected]',
expiration=(datetime.today() - timedelta(hours=24)),
mail_opt_out=False
)
user.set_password('test')
return user
@pytest.fixture(scope='module')
def test_client():
app = create_app(config_class=Config)
testing_client = app.test_client()
ctx = app.app_context()
ctx.push()
yield testing_client
ctx.pop()
@pytest.fixture(scope='module')
def init_database(new_user):
db.create_all()
db.session.add(new_user)
db.session.commit()
yield db
db.drop_all()