dev #11
|
|
@ -163,6 +163,57 @@ async def test_stage_rollback_allowed_for_admin(session: AsyncSession) -> None:
|
|||
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
|
||||
async def test_status_won_requires_positive_amount(session: AsyncSession) -> None:
|
||||
context, contact, repo = await _persist_base(session)
|
||||
|
|
|
|||
Loading…
Reference in New Issue