mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from sentry.models.project import Project
|
|
from sentry.services.hybrid_cloud.project.service import project_service
|
|
from sentry.testutils.factories import Factories
|
|
from sentry.testutils.pytest.fixtures import django_db_all
|
|
from sentry.testutils.silo import region_silo_test
|
|
|
|
|
|
@django_db_all(transaction=True)
|
|
@region_silo_test
|
|
def test_get_or_create_project():
|
|
org = Factories.create_organization()
|
|
user = Factories.create_user(email="[email protected]")
|
|
team = Factories.create_team(org)
|
|
|
|
project_service.get_or_create_project_for_organization(
|
|
organization_id=org.id,
|
|
project_name="test-project",
|
|
platform="java",
|
|
user_id=user.id,
|
|
add_org_default_team=True,
|
|
)
|
|
project = Project.objects.get(name="test-project")
|
|
assert project.platform == "java"
|
|
assert project.teams.filter(id=team.id).exists()
|
|
assert Project.objects.all().count() == 1
|
|
|
|
project_service.get_or_create_project_for_organization(
|
|
organization_id=org.id,
|
|
project_name="test-project",
|
|
platform="java",
|
|
user_id=user.id,
|
|
add_org_default_team=True,
|
|
)
|
|
assert Project.objects.all().count() == 1
|