diff --git a/tests/__init__.py b/tests/__init__.py index 4dcaf8bd..30bbb438 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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', @@ -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', @@ -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.... @@ -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;')