Completed
Push — main ( 19a6c5...d1ed65 )
by Jochen
03:53
created

tests.integration.api.conftest.api_app()   A

Complexity

Conditions 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2020 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 create_admin_app
11
from tests.conftest import CONFIG_PATH_DATA_KEY
12
13
from .helpers import assemble_authorization_header
14
15
16
API_TOKEN = 'just-say-PLEASE!'
17
18
19
@pytest.fixture(scope='package')
20
# `admin_app` fixture is required because it sets up the database.
21
def api_app(admin_app, make_admin_app):
22
    config_overrides = {
23
        'API_TOKEN': API_TOKEN,
24
        'SERVER_NAME': 'api.acmecon.test',
25
    }
26
    app = make_admin_app(**config_overrides)
27
    with app.app_context():
28
        yield app
29
30
31
@pytest.fixture(scope='package')
32
def api_client(api_app):
33
    """Provide a test HTTP client against the API."""
34
    return api_app.test_client()
35
36
37
@pytest.fixture(scope='package')
38
def api_client_authz_header():
39
    """Provide a test HTTP client against the API."""
40
    return assemble_authorization_header(API_TOKEN)
41