fix: add missing commas for syntax correctness across multiple files
Test / test (push) Successful in 15s
Test / test (push) Successful in 15s
This commit is contained in:
@@ -28,7 +28,7 @@ class Scenario:
|
||||
async def prepare_scenario(session_factory: async_sessionmaker[AsyncSession]) -> Scenario:
|
||||
async with session_factory() as session:
|
||||
user = User(
|
||||
email="owner@example.com", hashed_password="hashed", name="Owner", is_active=True
|
||||
email="owner@example.com", hashed_password="hashed", name="Owner", is_active=True,
|
||||
)
|
||||
org = Organization(name="Acme LLC")
|
||||
session.add_all([user, org])
|
||||
|
||||
@@ -32,7 +32,7 @@ async def prepare_analytics_scenario(
|
||||
async with session_factory() as session:
|
||||
org = Organization(name="Analytics Org")
|
||||
user = User(
|
||||
email="analytics@example.com", hashed_password="hashed", name="Analyst", is_active=True
|
||||
email="analytics@example.com", hashed_password="hashed", name="Analyst", is_active=True,
|
||||
)
|
||||
session.add_all([org, user])
|
||||
await session.flush()
|
||||
|
||||
@@ -61,7 +61,7 @@ async def test_list_user_organizations_returns_memberships(
|
||||
) -> None:
|
||||
async with session_factory() as session:
|
||||
user = User(
|
||||
email="owner@example.com", hashed_password="hashed", name="Owner", is_active=True
|
||||
email="owner@example.com", hashed_password="hashed", name="Owner", is_active=True,
|
||||
)
|
||||
session.add(user)
|
||||
await session.flush()
|
||||
@@ -115,10 +115,10 @@ async def test_owner_can_add_member_to_organization(
|
||||
) -> None:
|
||||
async with session_factory() as session:
|
||||
owner = User(
|
||||
email="owner-add@example.com", hashed_password="hashed", name="Owner", is_active=True
|
||||
email="owner-add@example.com", hashed_password="hashed", name="Owner", is_active=True,
|
||||
)
|
||||
invitee = User(
|
||||
email="new-member@example.com", hashed_password="hashed", name="Member", is_active=True
|
||||
email="new-member@example.com", hashed_password="hashed", name="Member", is_active=True,
|
||||
)
|
||||
session.add_all([owner, invitee])
|
||||
await session.flush()
|
||||
@@ -220,10 +220,10 @@ async def test_member_role_cannot_add_users(
|
||||
) -> None:
|
||||
async with session_factory() as session:
|
||||
member_user = User(
|
||||
email="member@example.com", hashed_password="hashed", name="Member", is_active=True
|
||||
email="member@example.com", hashed_password="hashed", name="Member", is_active=True,
|
||||
)
|
||||
invitee = User(
|
||||
email="invitee@example.com", hashed_password="hashed", name="Invitee", is_active=True
|
||||
email="invitee@example.com", hashed_password="hashed", name="Invitee", is_active=True,
|
||||
)
|
||||
session.add_all([member_user, invitee])
|
||||
await session.flush()
|
||||
@@ -266,10 +266,10 @@ async def test_cannot_add_duplicate_member(
|
||||
) -> None:
|
||||
async with session_factory() as session:
|
||||
owner = User(
|
||||
email="dup-owner@example.com", hashed_password="hashed", name="Owner", is_active=True
|
||||
email="dup-owner@example.com", hashed_password="hashed", name="Owner", is_active=True,
|
||||
)
|
||||
invitee = User(
|
||||
email="dup-member@example.com", hashed_password="hashed", name="Invitee", is_active=True
|
||||
email="dup-member@example.com", hashed_password="hashed", name="Invitee", is_active=True,
|
||||
)
|
||||
session.add_all([owner, invitee])
|
||||
await session.flush()
|
||||
|
||||
@@ -98,7 +98,7 @@ async def test_list_activities_returns_only_current_deal(session: AsyncSession)
|
||||
payload={"text": "hi"},
|
||||
),
|
||||
Activity(
|
||||
deal_id=deal_id + 1, author_id=context.user_id, type=ActivityType.SYSTEM, payload={}
|
||||
deal_id=deal_id + 1, author_id=context.user_id, type=ActivityType.SYSTEM, payload={},
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -120,7 +120,7 @@ async def test_add_comment_rejects_empty_text(session: AsyncSession) -> None:
|
||||
|
||||
with pytest.raises(ActivityValidationError):
|
||||
await service.add_comment(
|
||||
deal_id=deal_id, author_id=context.user_id, text=" ", context=context
|
||||
deal_id=deal_id, author_id=context.user_id, text=" ", context=context,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -39,16 +39,16 @@ async def session() -> AsyncGenerator[AsyncSession, None]:
|
||||
async def _seed_data(session: AsyncSession) -> tuple[int, int, int]:
|
||||
org = Organization(name="Analytics Org")
|
||||
user = User(
|
||||
email="analytics@example.com", hashed_password="hashed", name="Analyst", is_active=True
|
||||
email="analytics@example.com", hashed_password="hashed", name="Analyst", is_active=True,
|
||||
)
|
||||
session.add_all([org, user])
|
||||
await session.flush()
|
||||
|
||||
member = OrganizationMember(
|
||||
organization_id=org.id, user_id=user.id, role=OrganizationRole.OWNER
|
||||
organization_id=org.id, user_id=user.id, role=OrganizationRole.OWNER,
|
||||
)
|
||||
contact = Contact(
|
||||
organization_id=org.id, owner_id=user.id, name="Client", email="client@example.com"
|
||||
organization_id=org.id, owner_id=user.id, name="Client", email="client@example.com",
|
||||
)
|
||||
session.add_all([member, contact])
|
||||
await session.flush()
|
||||
|
||||
@@ -50,7 +50,7 @@ def jwt_service() -> JWTService:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_authenticate_success(
|
||||
password_hasher: PasswordHasher, jwt_service: JWTService
|
||||
password_hasher: PasswordHasher, jwt_service: JWTService,
|
||||
) -> None:
|
||||
hashed = password_hasher.hash("StrongPass123")
|
||||
user = User(email="user@example.com", hashed_password=hashed, name="Alice", is_active=True)
|
||||
@@ -103,7 +103,7 @@ async def test_refresh_tokens_returns_new_pair(
|
||||
jwt_service: JWTService,
|
||||
) -> None:
|
||||
user = User(
|
||||
email="refresh@example.com", hashed_password="hashed", name="Refresh", is_active=True
|
||||
email="refresh@example.com", hashed_password="hashed", name="Refresh", is_active=True,
|
||||
)
|
||||
user.id = 7
|
||||
service = AuthService(StubUserRepository(user), password_hasher, jwt_service)
|
||||
@@ -121,7 +121,7 @@ async def test_refresh_tokens_rejects_access_token(
|
||||
jwt_service: JWTService,
|
||||
) -> None:
|
||||
user = User(
|
||||
email="refresh@example.com", hashed_password="hashed", name="Refresh", is_active=True
|
||||
email="refresh@example.com", hashed_password="hashed", name="Refresh", is_active=True,
|
||||
)
|
||||
user.id = 9
|
||||
service = AuthService(StubUserRepository(user), password_hasher, jwt_service)
|
||||
|
||||
@@ -65,7 +65,7 @@ def _make_context(org: Organization, user: User, role: OrganizationRole) -> Orga
|
||||
|
||||
|
||||
async def _persist_base(
|
||||
session: AsyncSession, *, role: OrganizationRole = OrganizationRole.MANAGER
|
||||
session: AsyncSession, *, role: OrganizationRole = OrganizationRole.MANAGER,
|
||||
) -> tuple[
|
||||
OrganizationContext,
|
||||
Contact,
|
||||
|
||||
@@ -28,7 +28,7 @@ class StubOrganizationRepository(OrganizationRepository):
|
||||
self._membership = membership
|
||||
|
||||
async def get_membership(
|
||||
self, organization_id: int, user_id: int
|
||||
self, organization_id: int, user_id: int,
|
||||
) -> OrganizationMember | None: # pragma: no cover - helper
|
||||
if (
|
||||
self._membership
|
||||
@@ -40,7 +40,7 @@ class StubOrganizationRepository(OrganizationRepository):
|
||||
|
||||
|
||||
def make_membership(
|
||||
role: OrganizationRole, *, organization_id: int = 1, user_id: int = 10
|
||||
role: OrganizationRole, *, organization_id: int = 1, user_id: int = 10,
|
||||
) -> OrganizationMember:
|
||||
organization = Organization(name="Acme Inc")
|
||||
organization.id = organization_id
|
||||
@@ -75,7 +75,7 @@ class MembershipRepositoryStub(OrganizationRepository):
|
||||
"""Repository stub that can emulate duplicate checks for add_member."""
|
||||
|
||||
def __init__(
|
||||
self, memberships: dict[tuple[int, int], OrganizationMember] | None = None
|
||||
self, memberships: dict[tuple[int, int], OrganizationMember] | None = None,
|
||||
) -> None:
|
||||
self._session_stub = SessionStub()
|
||||
super().__init__(session=cast(AsyncSession, self._session_stub))
|
||||
@@ -95,7 +95,7 @@ async def test_get_context_success() -> None:
|
||||
service = OrganizationService(StubOrganizationRepository(membership))
|
||||
|
||||
context = await service.get_context(
|
||||
user_id=membership.user_id, organization_id=membership.organization_id
|
||||
user_id=membership.user_id, organization_id=membership.organization_id,
|
||||
)
|
||||
|
||||
assert context.organization_id == membership.organization_id
|
||||
@@ -183,7 +183,7 @@ async def test_add_member_rejects_duplicate_membership() -> None:
|
||||
|
||||
with pytest.raises(OrganizationMemberAlreadyExistsError):
|
||||
await service.add_member(
|
||||
context=context, user_id=duplicate_user_id, role=OrganizationRole.MANAGER
|
||||
context=context, user_id=duplicate_user_id, role=OrganizationRole.MANAGER,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ async def test_member_cannot_update_foreign_task(session: AsyncSession) -> None:
|
||||
role=OrganizationRole.MEMBER,
|
||||
)
|
||||
member_context = OrganizationContext(
|
||||
organization=context_owner.organization, membership=membership
|
||||
organization=context_owner.organization, membership=membership,
|
||||
)
|
||||
|
||||
with pytest.raises(TaskForbiddenError):
|
||||
|
||||
Reference in New Issue
Block a user