~homeworkprod/byceps

cf0d41a8d11498ae9ba0b60a6bc4c4b6ff341de0 — Jochen Kupperschmidt 3 months ago 944a75a
Setup test database only once, lift common test fixtures into session scope
M tests/conftest.py => tests/conftest.py +15 -15
@@ 45,7 45,7 @@ def make_admin_app(data_path):
    return _wrapper


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def admin_app(make_admin_app):
    """Provide the admin web application."""
    app = make_admin_app()


@@ 55,13 55,13 @@ def admin_app(make_admin_app):
        tear_down_database()


@pytest.fixture
@pytest.fixture(scope='session')
def admin_client(admin_app):
    """Provide a test HTTP client against the admin web application."""
    return admin_app.test_client()


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def make_party_app(admin_app, data_path):
    """Provide a party web application."""



@@ 73,7 73,7 @@ def make_party_app(admin_app, data_path):
    return _wrapper


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def party_app(make_party_app):
    """Provide a party web application."""
    app = make_party_app()


@@ 87,7 87,7 @@ def data_path():
        yield Path(d)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def make_user(admin_app):
    user_ids = set()



@@ 119,32 119,32 @@ def make_user_with_detail(admin_app):
        user_command_service.delete_account(user_id, user_id, 'clean up')


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def admin_user(make_user):
    return make_user('Admin')


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def user(make_user):
    return make_user('User')


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def uninitialized_user(make_user):
    return make_user('UninitializedUser', initialized=False)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def suspended_user(make_user):
    return make_user('SuspendedUser', suspended=True)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def deleted_user(make_user):
    return make_user('DeletedUser', deleted=True)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def make_email_config(admin_app):
    def _wrapper(
        config_id: str,


@@ 165,14 165,14 @@ def make_email_config(admin_app):
    return _wrapper


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def email_config(make_email_config):
    return make_email_config(
        DEFAULT_EMAIL_CONFIG_ID, sender_address='noreply@acmecon.test'
    )


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def site(email_config, party):
    site = create_site(
        'acmecon-2014-website',


@@ 184,14 184,14 @@ def site(email_config, party):
    site_service.delete_site(site.id)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def brand(admin_app):
    brand = create_brand()
    yield brand
    brand_service.delete_brand(brand.id)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def party(brand):
    party = create_party(brand.id)
    yield party

M tests/integration/announce/irc/conftest.py => tests/integration/announce/irc/conftest.py +1 -1
@@ 6,7 6,7 @@
import pytest


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def app(admin_app):
    admin_app.config.update({
        'ANNOUNCE_IRC_ENABLED': True,

M tests/integration/api/conftest.py => tests/integration/api/conftest.py +3 -3
@@ 16,7 16,7 @@ from .helpers import assemble_authorization_header
API_TOKEN = 'just-say-PLEASE!'


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def app(admin_app, data_path):
    config_overrides = {
        'API_TOKEN': API_TOKEN,


@@ 28,13 28,13 @@ def app(admin_app, data_path):
        yield app


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def api_client(app):
    """Provide a test HTTP client against the API."""
    return app.test_client()


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def api_client_authz_header():
    """Provide a test HTTP client against the API."""
    return assemble_authorization_header(API_TOKEN)

M tests/integration/blueprints/site/board/conftest.py => tests/integration/blueprints/site/board/conftest.py +6 -6
@@ 25,7 25,7 @@ from tests.helpers import (
from .helpers import create_board, create_category, create_posting, create_topic


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def board(site, brand):
    board = create_board(brand.id)



@@ 36,14 36,14 @@ def board(site, brand):
    board_service.delete_board(board.id)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def category(board):
    category = create_category(board.id, number=1)
    yield category
    _delete_category(category.id)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def another_category(board):
    category = create_category(board.id, number=2)
    yield category


@@ 72,12 72,12 @@ def posting(topic, board_poster):
    posting_command_service.delete_posting(posting.id)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def board_poster(make_user):
    return make_user('BoardPoster')


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def moderator(make_user):
    moderator = make_user('BoardModerator')



@@ 104,7 104,7 @@ def moderator(make_user):
        authorization_service.delete_permission(permission_id)


@pytest.fixture
@pytest.fixture(scope='session')
def moderator_client(party_app, moderator):
    with http_client(party_app, user_id=moderator.id) as client:
        yield client

M tests/integration/services/ticketing/conftest.py => tests/integration/services/ticketing/conftest.py +5 -5
@@ 8,30 8,30 @@ import pytest
from byceps.services.ticketing import category_service


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def category(party):
    category = category_service.create_category(party.id, 'Premium')
    yield category
    category_service.delete_category(category.id)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def another_category(party):
    category = category_service.create_category(party.id, 'Economy')
    yield category
    category_service.delete_category(category.id)


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def ticketing_admin(make_user):
    return make_user('TicketingAdmin')


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def ticket_manager(make_user):
    return make_user('TicketManager')


@pytest.fixture(scope='module')
@pytest.fixture(scope='session')
def ticket_owner(make_user):
    return make_user('TicketOwner')