Skip to content

Commit

Permalink
Test setup for db extensions
Browse files Browse the repository at this point in the history
ref T35707
  • Loading branch information
Maciej Lewinski committed May 30, 2022
1 parent 8c2b433 commit 7f3769d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
else:
db_settings = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'binder-test',
'HOST': 'localhost',
'USER': 'postgres',
Expand All @@ -51,6 +51,11 @@
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
*(
['django.contrib.postgres']
if db_settings['ENGINE'] == 'django.db.backends.postgresql' else
[]
),
'binder',
'binder.plugins.token_auth',
'tests',
Expand Down Expand Up @@ -116,7 +121,7 @@
# Do the dance to ensure the models are synched to the DB.
# This saves us from having to include migrations
from django.core.management.commands.migrate import Command as MigrationCommand # noqa
from django.db import connections # noqa
from django.db import connection, connections # noqa
from django.db.migrations.executor import MigrationExecutor # noqa

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


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

0 comments on commit 7f3769d

Please sign in to comment.