oncall-engine/engine/apps/user_management/tests/test_team.py
Matias Bordese 7e3008ba0f
Setup team uniqueness at DB level (#4396)
Avoid potential duplicated teams. Also it should help ensuring
`sync_organization` idempotency.
2024-05-27 17:41:20 +00:00

14 lines
399 B
Python

import pytest
from django.db.utils import IntegrityError
@pytest.mark.django_db
def test_team_uniqueness(make_organization):
organization = make_organization()
# Create a team
organization.teams.create(name="Team 1", team_id=1)
# Try to create another team with the same team_id
with pytest.raises(IntegrityError):
organization.teams.create(name="Team 2", team_id=1)