Skip to content

Commit

Permalink
Add social pipeline tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wojcikmat committed May 22, 2024
1 parent 9d50efd commit ab56de2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/backend/apps/multitenancy/tests/test_pipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest
from ..pipeline import create_default_tenant

from ..models import Tenant
from ..constants import TenantType

pytestmark = pytest.mark.django_db


class TestCreateTenantPipeline:
def test_create_default_tenant_user_and_is_new(self, user):
create_default_tenant(user=user, is_new=True)
tenant_exists = Tenant.objects.filter(creator=user, type=TenantType.DEFAULT).exists()
assert tenant_exists

def test_create_default_tenant_user_not_new(self, user):
count_before = Tenant.objects.filter(creator=user, type=TenantType.DEFAULT).count()
create_default_tenant(user=user, is_new=False)
count_after = Tenant.objects.filter(creator=user, type=TenantType.DEFAULT).count()
assert count_before == count_after

def test_create_default_tenant_no_user(self):
create_default_tenant(user=None, is_new=True)
tenant_exists = Tenant.objects.exists()
assert not tenant_exists

0 comments on commit ab56de2

Please sign in to comment.