~homeworkprod/byceps

8849086179d6e3735de34421bea16cf43b33a0bd — Jochen Kupperschmidt 1 year, 5 months ago 4f05d39
*Return* (not `yield`) in user factory fixture's wrapper

Inline unnecessary `make_user`-based fixtures along the way.
M tests/api/v1/attendance/test_create_archived_attendance.py => tests/api/v1/attendance/test_create_archived_attendance.py +1 -1
@@ 10,7 10,7 @@ from byceps.services.ticketing import attendance_service

@pytest.fixture
def another_user(make_user):
    yield from make_user('AnotherUser')
    return make_user('AnotherUser')


def test_create_archived_attendance(

M tests/blueprints/admin/newsletter/test_views.py => tests/blueprints/admin/newsletter/test_views.py +2 -7
@@ 92,13 92,8 @@ def test_export_subscriber_email_addresses(newsletter_list, subscribers, client)


@pytest.fixture(scope='module')
def _newsletter_admin(make_user):
    yield from make_user('NewsletterAdmin')


@pytest.fixture(scope='module')
def newsletter_admin(_newsletter_admin):
    admin = _newsletter_admin
def newsletter_admin(make_user):
    admin = make_user('NewsletterAdmin')

    permission_ids = {'admin.access', 'newsletter.export_subscribers'}
    role_id = 'newsletter_admin'

M tests/blueprints/admin/shop/order/test_order_export.py => tests/blueprints/admin/shop/order/test_order_export.py +4 -16
@@ 27,13 27,8 @@ from tests.services.shop.helpers import create_article as _create_article


@pytest.fixture(scope='module')
def _admin_user(make_user):
    yield from make_user('ShopOrderAdmin')


@pytest.fixture(scope='module')
def admin_user(_admin_user):
    admin = _admin_user
def admin_user(make_user):
    admin = make_user('ShopOrderAdmin')

    permission_ids = {'admin.access', 'shop_order.view'}
    role_id = 'order_admin'


@@ 111,15 106,8 @@ def cart(article_bungalow, article_guest_fee, article_table):


@pytest.fixture
def _orderer(make_user):
    yield from make_user(
        'Besteller', email_address='h-w.mustermann@users.test'
    )


@pytest.fixture
def orderer(_orderer):
    user = _orderer
def orderer(make_user):
    user = make_user('Besteller', email_address='h-w.mustermann@users.test')

    return Orderer(
        user.id,

M tests/blueprints/admin/shop/order/test_views.py => tests/blueprints/admin/shop/order/test_views.py +2 -7
@@ 41,13 41,8 @@ def order_number_sequence(shop) -> None:


@pytest.fixture(scope='module')
def _admin(make_user):
    yield from make_user('ShopOrderAdmin')


@pytest.fixture(scope='module')
def admin(_admin):
    admin = _admin
def admin(make_user):
    admin = make_user('ShopOrderAdmin')

    permission_ids = {
        'admin.access',

M tests/blueprints/authentication/test_views_password_update.py => tests/blueprints/authentication/test_views_password_update.py +1 -1
@@ 14,7 14,7 @@ from tests.helpers import http_client, login_user

@pytest.fixture
def user(make_user):
    yield from make_user('PasswordUpdater')
    return make_user('PasswordUpdater')


def test_when_logged_in_endpoint_is_available(party_app, site, user):

M tests/blueprints/site/board/conftest.py => tests/blueprints/site/board/conftest.py +5 -10
@@ 72,19 72,14 @@ def posting(topic, board_poster):
    posting_command_service.delete_posting(posting.id)


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


@pytest.fixture
def _moderator(make_user):
    yield from make_user('BoardModerator')


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

    permission_ids = {
        'board.hide',

M tests/blueprints/user/test_views_create.py => tests/blueprints/user/test_views_create.py +1 -1
@@ 35,7 35,7 @@ from tests.helpers import create_site, http_client

@pytest.fixture(scope='module')
def user_admin(make_user):
    yield from make_user('UserAdmin')
    return make_user('UserAdmin')


@pytest.fixture(scope='module')

M tests/blueprints/user/test_views_email_address_confirmation.py => tests/blueprints/user/test_views_email_address_confirmation.py +4 -4
@@ 12,14 12,14 @@ from byceps.services.verification_token.models import Purpose, Token
from tests.helpers import http_client


@pytest.fixture
@pytest.fixture(scope='module')
def user1(make_user):
    yield from make_user('User1', initialized=False)
    return make_user('User1', initialized=False)


@pytest.fixture
@pytest.fixture(scope='module')
def user2(make_user):
    yield from make_user('User2', initialized=False)
    return make_user('User2', initialized=False)


@pytest.fixture

M tests/conftest.py => tests/conftest.py +17 -13
@@ 85,38 85,42 @@ def data_path():

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

    def _wrapper(*args, **kwargs):
        user = create_user(*args, **kwargs)
        user_id = user.id
        yield user
        user_command_service.delete_account(user_id, user_id, 'clean up')
        user_ids.add(user.id)
        return user

    yield _wrapper

    for user_id in user_ids:
        user_command_service.delete_account(user_id, user_id, 'clean up')

@pytest.fixture

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


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


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


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


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


@pytest.fixture(scope='module')

M tests/services/authorization/test_deassign_all_roles_from_user.py => tests/services/authorization/test_deassign_all_roles_from_user.py +2 -2
@@ 30,12 30,12 @@ def test_deassign_all_roles_from_user(admin_app, user1, user2, roles):

@pytest.fixture
def user1(make_user):
    yield from make_user('User1')
    return make_user('User1')


@pytest.fixture
def user2(make_user):
    yield from make_user('User2')
    return make_user('User2')


@pytest.fixture

M tests/services/news/test_models.py => tests/services/news/test_models.py +2 -2
@@ 11,9 11,9 @@ from byceps.services.news import (
)


@pytest.fixture
@pytest.fixture(scope='module')
def editor(make_user):
    yield from make_user('NewsEditor')
    return make_user('NewsEditor')


@pytest.fixture(scope='module')

M tests/services/ticketing/conftest.py => tests/services/ticketing/conftest.py +4 -4
@@ 24,19 24,19 @@ def another_category(party):

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


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


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


@pytest.fixture(scope='module')
def ticket_user(make_user):
    yield from make_user('TicketUser')
    return make_user('TicketUser')

M tests/services/user/test_find_user.py => tests/services/user/test_find_user.py +1 -1
@@ 10,7 10,7 @@ from byceps.services.user import service as user_service

@pytest.fixture(scope='module')
def user(make_user):
    yield from make_user(
    return make_user(
        'CarmenSandiego', email_address='carmen.sandiego@world.example'
    )


M tests/services/user/test_initialize.py => tests/services/user/test_initialize.py +6 -6
@@ 11,19 11,19 @@ from byceps.services.user import command_service as user_command_service
from byceps.services.user import event_service


@pytest.fixture
@pytest.fixture(scope='module')
def uninitialized_user_created_online(make_user):
    yield from make_user('CreatedOnline', initialized=False)
    return make_user('CreatedOnline', initialized=False)


@pytest.fixture
@pytest.fixture(scope='module')
def uninitialized_user_created_at_party_checkin_by_admin(make_user):
    yield from make_user('CreatedAtPartyCheckInByAdmin', initialized=False)
    return make_user('CreatedAtPartyCheckInByAdmin', initialized=False)


@pytest.fixture
@pytest.fixture(scope='module')
def already_initialized_user(make_user):
    yield from make_user('AlreadyInitialized')
    return make_user('AlreadyInitialized')


@pytest.fixture

M tests/services/user/test_suspend_unsuspend.py => tests/services/user/test_suspend_unsuspend.py +2 -2
@@ 12,12 12,12 @@ from byceps.services.user import service as user_service

@pytest.fixture
def cheater(make_user):
    yield from make_user('Cheater')
    return make_user('Cheater')


@pytest.fixture
def remorseful_user(make_user):
    yield from make_user('TemporaryNuisance')
    return make_user('TemporaryNuisance')


def test_suspend(admin_app, cheater, admin_user):

M tests/services/user_badge/test_service_awarding.py => tests/services/user_badge/test_service_awarding.py +3 -3
@@ 20,17 20,17 @@ from byceps.services.user_badge.transfer.models import QuantifiedBadgeAwarding

@pytest.fixture(scope='module')
def user1(make_user):
    yield from make_user('Stullenandi')
    return make_user('Stullenandi')


@pytest.fixture(scope='module')
def user2(make_user):
    yield from make_user('Anica')
    return make_user('Anica')


@pytest.fixture(scope='module')
def user3(make_user):
    yield from make_user('Slobo')
    return make_user('Slobo')


@pytest.fixture(scope='module')