Skip to content

Commit 29b6615

Browse files
committed
age rating fixture refactoring
1 parent 5a2c767 commit 29b6615

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

tests/fixtures/entities.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,27 @@ def build_workplace(**fields):
534534
return Workplace(**fields)
535535

536536

537+
def build_age_rating(name: str, description: str) -> AgeRating:
538+
return AgeRating(
539+
name=name,
540+
description=description,
541+
)
542+
543+
537544
async def create_workplace(async_session: AsyncSession, **fields):
538545
workplace = build_workplace(**fields)
539546
async_session.add(workplace)
540547
await async_session.commit()
541548
return workplace
542549

543550

551+
async def create_age_rating(async_session: AsyncSession, **fields):
552+
age_rating = build_age_rating(**fields)
553+
async_session.add(age_rating)
554+
await async_session.commit()
555+
return age_rating
556+
557+
544558
@async_fixture()
545559
async def workplace_1(
546560
async_session: AsyncSession,
@@ -556,8 +570,9 @@ async def workplace_2(
556570

557571

558572
@async_fixture()
559-
async def age_rating_g(async_session: AsyncSession):
560-
age_rating = AgeRating(
573+
async def age_rating_g(async_session: AsyncSession) -> AgeRating:
574+
return await create_age_rating(
575+
async_session=async_session,
561576
name="G",
562577
description=dedent(
563578
"""G – General Audiences
@@ -567,7 +582,3 @@ async def age_rating_g(async_session: AsyncSession):
567582
""",
568583
),
569584
)
570-
async_session.add(age_rating)
571-
await async_session.commit()
572-
573-
return age_rating

0 commit comments

Comments
 (0)