tests: truncate database name to 63 characters

This commit is contained in:
Benjamin Dauvergne 2021-03-02 13:57:29 +01:00
parent d5b56715f3
commit 1d712335ef
6 changed files with 9 additions and 6 deletions

View File

@ -19,6 +19,6 @@ HOBO_MANAGER_HOMEPAGE_URL_VAR = 'portal_agent_url'
DATABASES = {
'default': {
'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.sqlite3'),
'TEST': {'NAME': 'hobo-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-')[:63],},
'TEST': {'NAME': ('hobo-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-'))[:63],},
}
}

View File

@ -16,7 +16,7 @@ with patch.object(builtins, 'open', mock_open(read_data=b'xxx')):
BRANCH_NAME = os.environ.get("BRANCH_NAME", "").replace('/', '-')
DATABASES['default']['TEST'] = {
'NAME': DATABASES['default']['NAME'] + '-%s' % BRANCH_NAME,
'NAME': (DATABASES['default']['NAME'] + '-%s' % BRANCH_NAME)[:63],
}
# Avoid conflic with real tenants

View File

@ -18,7 +18,7 @@ with patch.object(builtins, 'open', mock_open(read_data=b'xxx')):
BRANCH_NAME = os.environ.get("BRANCH_NAME", "").replace('/', '-')
DATABASES['default']['TEST'] = {
'NAME': DATABASES['default']['NAME'] + '-%s' % BRANCH_NAME,
'NAME': (DATABASES['default']['NAME'] + '-%s' % BRANCH_NAME)[:63],
}
CACHES = {

View File

@ -50,7 +50,7 @@ with patch.object(builtins, 'open', mock_open(read_data=b'xxx')):
BRANCH_NAME = os.environ.get("BRANCH_NAME", "").replace('/', '-')
DATABASES['default']['TEST'] = {
'NAME': DATABASES['default']['NAME'] + '-%s' % BRANCH_NAME,
'NAME': (DATABASES['default']['NAME'] + '-%s' % BRANCH_NAME)[:63],
}
TENANT_APPS = ('django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes',

View File

@ -18,7 +18,7 @@ with patch.object(builtins, 'open', mock_open(read_data=b'xxx')):
BRANCH_NAME = os.environ.get("BRANCH_NAME", "").replace('/', '-')
DATABASES['default']['TEST'] = {
'NAME': DATABASES['default']['NAME'] + '-%s' % BRANCH_NAME,
'NAME': (DATABASES['default']['NAME'] + '-%s' % BRANCH_NAME)[:63],
}
# Avoid conflic with real tenants

View File

@ -1,11 +1,14 @@
import os
import tempfile
TENANT_BASE = tempfile.mkdtemp('hobo-tenant-base')
TENANT_MODEL = 'multitenant.Tenant'
MIDDLEWARE = ('hobo.multitenant.middleware.TenantMiddleware',) + MIDDLEWARE
BRANCH_NAME = os.environ.get("BRANCH_NAME", "").replace('/', '_').replace('-', '_').encode('ascii', 'ignore').decode()
DATABASES = {
'default': {
'ENGINE': 'tenant_schemas.postgresql_backend',
'NAME': 'test_hobo',
'TEST': {'NAME': ('hobo_test_schemas_' + BRANCH_NAME)[:63]},
}
}
DATABASE_ROUTERS = ('tenant_schemas.routers.TenantSyncRouter',)