File: conftest.py

package info (click to toggle)
python-authlib 1.6.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,024 kB
  • sloc: python: 27,412; makefile: 53; sh: 14
file content (48 lines) | stat: -rw-r--r-- 900 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
48
import os

import pytest
from flask import Flask


@pytest.fixture(autouse=True)
def env():
    os.environ["AUTHLIB_INSECURE_TRANSPORT"] = "true"
    yield
    del os.environ["AUTHLIB_INSECURE_TRANSPORT"]


@pytest.fixture
def app():
    app = Flask(__name__)
    app.debug = True
    app.testing = True
    app.secret_key = "testing"
    app.config.update(
        {
            "OAUTH1_SUPPORTED_SIGNATURE_METHODS": [
                "PLAINTEXT",
                "HMAC-SHA1",
                "RSA-SHA1",
            ],
            "SQLALCHEMY_TRACK_MODIFICATIONS": False,
            "SQLALCHEMY_DATABASE_URI": "sqlite://",
        }
    )

    with app.app_context():
        yield app


@pytest.fixture
def test_client(app, db):
    return app.test_client()


@pytest.fixture
def db(app):
    from .oauth1_server import db

    db.init_app(app)
    db.create_all()
    yield db
    db.drop_all()