Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2021 Alexander Todorov <atodorov@MrSenko.com> | ||
|
||
# Licensed under the GPL 3.0: https://www.gnu.org/licenses/gpl-3.0.txt | ||
# pylint: disable=too-many-ancestors | ||
from django.test import override_settings | ||
from django_tenants import utils as django_tenant_utils | ||
|
||
from tcms_tenants import utils | ||
from tcms_tenants.tests import LoggedInTestCase | ||
|
||
|
||
class TenantDomainTestCase(LoggedInTestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
|
||
with utils.schema_context('public'): | ||
cls.tenant2 = django_tenant_utils.get_tenant_model()( | ||
schema_name='other2', | ||
owner=cls.tester) | ||
cls.tenant2.save() | ||
|
||
cls.domain2 = django_tenant_utils.get_tenant_domain_model()( | ||
tenant=cls.tenant2, | ||
domain='other2.example.com') | ||
cls.domain2.save() | ||
|
||
def test_should_return_existing_domain_from_db(self): | ||
with override_settings(KIWI_TENANTS_DOMAIN='qa.kiwitcms.org'): | ||
result = utils.tenant_domain(self.tenant2.schema_name) | ||
self.assertEqual(result, "other2.example.com") | ||
|
||
def test_should_fallback_to_prefix_and_settings_when_domain_doesnt_exist(self): | ||
with override_settings(KIWI_TENANTS_DOMAIN='qa.kiwitcms.org'): | ||
result = utils.tenant_domain('public') | ||
self.assertEqual(result, "public.qa.kiwitcms.org") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters