aboutsummaryrefslogtreecommitdiff
path: root/app/tests/conftest.py
blob: 68af9e5f81e9defc6d9054872f3212f35740d37a (plain)
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
# -*- coding: utf-8 -*-
"""
Configuration with basic fixtures
"""
import pytest

from app import app as flask_app
from app import db
import tempfile
import os


@pytest.fixture
def app():
    """
    Special configurations for tests

    We use a dummy database and initialise it.
    """
    flask_app.config["WTF_CSRF_ENABLED"] = False
    flask_app.config["SQLALCHEMY_DATABASE_URI"] = (
        "sqlite:///" + tempfile.mkstemp(suffix=".db")[-1]
    )
    flask_app.config["MAIL_BACKEND"] = "file"  # "locmem"
    flask_app.config["MAIL_FILE_PATH"] = "/tmp/app-messages"
    db.create_all()
    yield flask_app


@pytest.fixture
def client(app):
    return app.test_client()