feat: add tests for deal stage rollback and forward transitions for owner and member roles
Test / test (push) Successful in 14s
Details
Test / test (push) Successful in 14s
Details
This commit is contained in:
parent
ce652a7e48
commit
1c206323a2
|
|
@ -163,6 +163,57 @@ async def test_stage_rollback_allowed_for_admin(session: AsyncSession) -> None:
|
||||||
assert updated.stage == DealStage.PROPOSAL
|
assert updated.stage == DealStage.PROPOSAL
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_stage_rollback_allowed_for_owner(session: AsyncSession) -> None:
|
||||||
|
context, contact, repo = await _persist_base(session, role=OrganizationRole.OWNER)
|
||||||
|
service = DealService(repository=repo)
|
||||||
|
|
||||||
|
deal = await service.create_deal(
|
||||||
|
DealCreate(
|
||||||
|
organization_id=context.organization_id,
|
||||||
|
contact_id=contact.id,
|
||||||
|
owner_id=context.user_id,
|
||||||
|
title="Owner Rollback",
|
||||||
|
amount=Decimal("2500"),
|
||||||
|
),
|
||||||
|
context=context,
|
||||||
|
)
|
||||||
|
deal.stage = DealStage.CLOSED
|
||||||
|
|
||||||
|
updated = await service.update_deal(
|
||||||
|
deal,
|
||||||
|
DealUpdateData(stage=DealStage.NEGOTIATION),
|
||||||
|
context=context,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert updated.stage == DealStage.NEGOTIATION
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_stage_forward_allowed_for_member(session: AsyncSession) -> None:
|
||||||
|
context, contact, repo = await _persist_base(session, role=OrganizationRole.MEMBER)
|
||||||
|
service = DealService(repository=repo)
|
||||||
|
|
||||||
|
deal = await service.create_deal(
|
||||||
|
DealCreate(
|
||||||
|
organization_id=context.organization_id,
|
||||||
|
contact_id=contact.id,
|
||||||
|
owner_id=context.user_id,
|
||||||
|
title="Forward Move",
|
||||||
|
amount=Decimal("1000"),
|
||||||
|
),
|
||||||
|
context=context,
|
||||||
|
)
|
||||||
|
|
||||||
|
updated = await service.update_deal(
|
||||||
|
deal,
|
||||||
|
DealUpdateData(stage=DealStage.PROPOSAL),
|
||||||
|
context=context,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert updated.stage == DealStage.PROPOSAL
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_status_won_requires_positive_amount(session: AsyncSession) -> None:
|
async def test_status_won_requires_positive_amount(session: AsyncSession) -> None:
|
||||||
context, contact, repo = await _persist_base(session)
|
context, contact, repo = await _persist_base(session)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue