Skip to content

Commit 2d5931b

Browse files
Maciej Lewinskimacias
authored andcommitted
Test setup for db extensions
ref T35707
1 parent 4c89a57 commit 2d5931b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
else:
2727
db_settings = {
28-
'ENGINE': 'django.db.backends.postgresql_psycopg2',
28+
'ENGINE': 'django.db.backends.postgresql',
2929
'NAME': 'binder-test',
3030
'HOST': 'localhost',
3131
'USER': 'postgres',
@@ -51,6 +51,11 @@
5151
'django.contrib.auth',
5252
'django.contrib.contenttypes',
5353
'django.contrib.sessions',
54+
*(
55+
['django.contrib.postgres']
56+
if db_settings['ENGINE'] == 'django.db.backends.postgresql' else
57+
[]
58+
),
5459
'binder',
5560
'binder.plugins.token_auth',
5661
'tests',
@@ -116,7 +121,7 @@
116121
# Do the dance to ensure the models are synched to the DB.
117122
# This saves us from having to include migrations
118123
from django.core.management.commands.migrate import Command as MigrationCommand # noqa
119-
from django.db import connections # noqa
124+
from django.db import connection, connections # noqa
120125
from django.db.migrations.executor import MigrationExecutor # noqa
121126

122127
# This is oh so hacky....
@@ -132,3 +137,8 @@
132137
Permission.objects.get_or_create(content_type=content_type, codename='view_country')
133138
call_command('define_groups')
134139

140+
141+
# Create postgres extensions
142+
if db_settings['ENGINE'] == 'django.db.backends.postgresql':
143+
with connection.cursor() as cursor:
144+
cursor.execute('CREATE EXTENSION IF NOT EXISTS unaccent;')

0 commit comments

Comments
 (0)