Passed
Push — master ( eac89f...82ee7b )
by Jochen
02:16
created

tests.api.conftest.api_client_authz_header()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2019 Jochen Kupperschmidt
3
:License: Modified BSD, see LICENSE for details.
4
5
API-specific fixtures
6
"""
7
8
import pytest
9
10
from tests.base import CONFIG_FILENAME_TEST_ADMIN, create_app
11
from tests.helpers import create_brand, create_party, create_user
12
13
from ..conftest import database_recreated
14
15
from .helpers import assemble_authorization_header
16
17
18
API_TOKEN = 'just-say-PLEASE!'
19
20
21
@pytest.fixture(scope='session')
22
def api_app_without_db(db):
23
    app = create_app(CONFIG_FILENAME_TEST_ADMIN, {'API_TOKEN': API_TOKEN})
24
    with app.app_context():
25
        yield app
26
27
28
@pytest.fixture(scope='module')
29
def app(api_app_without_db, db):
30
    app = api_app_without_db
31
    with database_recreated(db):
32
        yield app
33
34
35
@pytest.fixture(scope='module')
36
def party(app):
37
    brand = create_brand()
38
    return create_party(brand.id)
39
40
41
@pytest.fixture(scope='module')
42
def admin(app):
43
    return create_user('Admin')
44
45
46
@pytest.fixture(scope='module')
47
def user(app):
48
    return create_user('User')
49
50
51
@pytest.fixture(scope='module')
52
def api_client(app):
53
    """Provide a test HTTP client against the API."""
54
    return app.test_client()
55
56
57
@pytest.fixture(scope='module')
58
def api_client_authz_header():
59
    """Provide a test HTTP client against the API."""
60
    return assemble_authorization_header(API_TOKEN)
61