Spaces:
Running
Running
File size: 1,388 Bytes
7cc81cb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | import pytest
from app.projects.repositories.collaboration_repository import CollaborationRepository
from app.projects.services.collaboration_service import CollaborationService
@pytest.mark.asyncio
async def test_collaboration_team_lifecycle(db_session):
repo = CollaborationRepository(db_session)
service = CollaborationService(repo)
workspace_id = "test_workspace"
# 1. Create Team
team = await service.create_team(workspace_id, "Engineering")
assert team.name == "Engineering"
# 2. List Teams
teams = await service.list_teams(workspace_id)
assert len(teams) >= 1
# 3. Update Team
updated = await service.update_team(workspace_id, team.id, "Product")
assert updated.name == "Product"
# 4. Archive
await service.archive_team(workspace_id, team.id)
teams = await service.list_teams(workspace_id)
assert not any(t.id == team.id for t in teams)
@pytest.mark.asyncio
async def test_collaboration_invitation_lifecycle(db_session):
repo = CollaborationRepository(db_session)
service = CollaborationService(repo)
workspace_id = "test_workspace"
email = "test@example.com"
# Test invitation
invitation = await service.invite_member(workspace_id, email, "member")
assert invitation.email == email
assert hasattr(invitation, "token") # Check if token is returned
|