def test_create_todo_group(self): connection.set_tenant(self.tenant_2) TodoGroup.objects.create(name='todo group') count = TodoGroup.objects.all().count() self.assertEquals(count, 2) connection.set_tenant(self.tenant) count = TodoGroup.objects.all().count() self.assertEquals(count, 0) connection.set_schema_to_public()
def create_account(data): account = AccountSerializer(data=data) account.is_valid(raise_exception=True) connection.set_schema_to_public() username = data['username'] tenant = Tenant.objects.create(schema_name=username) connection.set_tenant(tenant) domain = Domain() domain.tenant = tenant domain.domain = f"{username}.{APPLICATION_DOMAIN}" account.save() domain.save()
def setUpTestData(cls): connection.set_schema_to_public() cls.tenant = Tenant.objects.create(schema_name='tenant1') cls.tenant_domain = Domain() cls.tenant_domain.tenant = cls.tenant cls.tenant_domain.domain = 'tenant1.djangoredux.com' cls.tenant_domain.save() connection.set_tenant(cls.tenant) cls.account = Account.objects.create_superuser('tenant user', 'user', 'Tu112231') connection.set_schema_to_public()
def setUp(self): connection.set_schema_to_public() connection.set_tenant(self.tenant) self.group_1 = TodoGroup.objects.create(name='todo group') connection.set_schema_to_public() self.tenant_2 = Tenant.objects.create(schema_name='tenant2') connection.set_tenant(self.tenant_2) self.group_2 = TodoGroup.objects.create(name='todo group 2') connection.set_schema_to_public()
def setUp(self): connection.set_schema_to_public() self.tenant.refresh_from_db() connection.set_tenant(self.tenant) self.account.refresh_from_db()