~homeworkprod/byceps

a32331d21f19115b53389650baeda6a014700b16 — Jochen Kupperschmidt a month ago c98d51b
Introduce brand fixture factory, remove `create_brand` test helper
3 files changed, 20 insertions(+), 17 deletions(-)

M tests/conftest.py
M tests/helpers.py
M tests/integration/services/brand/test_settings_service.py
M tests/conftest.py => tests/conftest.py +17 -5
@@ 25,7 25,6 @@ from byceps.typing import BrandID
from tests.base import create_admin_app, create_site_app
from tests.database import set_up_database, tear_down_database
from tests.helpers import (
    create_brand,
    create_party,
    create_permissions,
    create_role_with_permissions_assigned,


@@ 244,10 243,23 @@ def site(email_config, party, board):


@pytest.fixture(scope='session')
def brand(admin_app):
    brand = create_brand()
    yield brand
    brand_service.delete_brand(brand.id)
def make_brand(admin_app):
    brands = []

    def _wrapper(brand_id, title):
        brand = brand_service.create_brand(brand_id, title)
        brands.append(brand)
        return brand

    yield _wrapper

    for brand in brands:
        brand_service.delete_brand(brand.id)


@pytest.fixture(scope='session')
def brand(make_brand):
    return make_brand('acmecon', 'ACME Entertainment Convention')


@pytest.fixture(scope='session')

M tests/helpers.py => tests/helpers.py +0 -5
@@ 15,7 15,6 @@ from byceps.application import create_app
from byceps.database import db, generate_uuid
from byceps.services.authentication.session import service as session_service
from byceps.services.authorization import service as authz_service
from byceps.services.brand import service as brand_service
from byceps.services.party import service as party_service
from byceps.services.site import service as site_service
from byceps.services.user import creation_service as user_creation_service


@@ 167,10 166,6 @@ def create_role_with_permissions_assigned(role_id, permission_ids):
        authz_service.assign_permission_to_role(permission_id, role_id)


def create_brand(brand_id='acmecon', title='ACME Entertainment Convention'):
    return brand_service.create_brand(brand_id, title)


def create_party(brand_id, party_id='acmecon-2014', title='ACMECon 2014'):
    starts_at = datetime(2014, 10, 24, 16, 0)
    ends_at = datetime(2014, 10, 26, 13, 0)

M tests/integration/services/brand/test_settings_service.py => tests/integration/services/brand/test_settings_service.py +3 -7
@@ 5,20 5,16 @@

import pytest

from byceps.services.brand import service as brand_service, settings_service
from byceps.services.brand import settings_service
from byceps.services.brand.transfer.models import BrandSetting

from tests.helpers import create_brand


BRAND_ID = 'value-brand'


@pytest.fixture(scope='module')
def brand(admin_app):
    brand = create_brand(BRAND_ID, 'ValueBrand')
    yield brand
    brand_service.delete_brand(brand.id)
def brand(make_brand):
    return make_brand(BRAND_ID, 'ValueBrand')


def test_create(brand):