Skip to content

Commit

Permalink
Merge d7bfa5e into 622f1bc
Browse files Browse the repository at this point in the history
  • Loading branch information
pyup-bot committed Apr 27, 2020
2 parents 622f1bc + d7bfa5e commit e293cce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1 +1 @@
django-tenants==3.0.3
django-tenants==3.1.0
8 changes: 8 additions & 0 deletions tcms_tenants/tests/__init__.py
Expand Up @@ -25,6 +25,14 @@ class Meta:


class LoggedInTestCase(FastTenantTestCase):
@classmethod
def get_test_schema_name(cls):
return 'fast'

@classmethod
def get_test_tenant_domain(cls):
return 'tenant.fast-test.com'

@classmethod
def setup_tenant(cls, tenant):
tenant.owner = UserFactory()
Expand Down
4 changes: 2 additions & 2 deletions tcms_tenants/tests/test_storage.py
Expand Up @@ -45,12 +45,12 @@ def test_files_are_saved_under_subdirectories_per_tenant(self):

# assert the paths are correct
self.assertTrue(public_os_path.endswith('apps_dir/media/public/%s' % public_file_name))
self.assertTrue(t1_os_path.endswith('apps_dir/media/test/%s' % t1_file_name))
self.assertTrue(t1_os_path.endswith('apps_dir/media/fast/%s' % t1_file_name))
self.assertTrue(t2_os_path.endswith('apps_dir/media/tenant2/%s' % t2_file_name))

# assert urls are correct
self.assertEqual(public_url, '/media/public/%s' % public_file_name)
self.assertEqual(t1_url, '/media/test/%s' % t1_file_name)
self.assertEqual(t1_url, '/media/fast/%s' % t1_file_name)
self.assertEqual(t2_url, '/media/tenant2/%s' % t2_file_name)

# assert contents are correct
Expand Down
9 changes: 7 additions & 2 deletions tcms_tenants/tests/test_views.py
Expand Up @@ -18,18 +18,23 @@

class RedirectToTestCase(LoggedInTestCase):
def test_redirect_to_tenant_path(self):
expected_url = 'https://test.%s/plans/search/' % settings.KIWI_TENANTS_DOMAIN
expected_url = 'https://%s.%s/plans/search/' % (self.get_test_schema_name(),
settings.KIWI_TENANTS_DOMAIN)
response = self.client.get(reverse('tcms_tenants:redirect-to',
args=[self.tenant.schema_name, 'plans/search/']))

self.assertIsInstance(response, HttpResponseRedirect)
self.assertEqual(response['Location'], expected_url)

def test_redirect_to_tenant_root_url(self):
expected_url = 'https://test.%s/' % settings.KIWI_TENANTS_DOMAIN
expected_url = 'https://%s.%s/' % (self.get_test_schema_name(),
settings.KIWI_TENANTS_DOMAIN)
response = self.client.get(reverse('tcms_tenants:redirect-to',
args=[self.tenant.schema_name, '']))

print('+++ DEBUG: expected_url', expected_url)
print('+++ ACTUAL:', response['Location'])

self.assertIsInstance(response, HttpResponseRedirect)
self.assertEqual(response['Location'], expected_url)

Expand Down

0 comments on commit e293cce

Please sign in to comment.