From b9e8f4ee3f2a6e8969fcd04a93da16078e3d972e Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 29 Sep 2015 19:37:28 +0200 Subject: [PATCH 2/8] multitenant: allow testing multitenant applications (#8425) Django setup of db for tests always call "migrate" which the multitenant application inactivate. This commit redirect this command to migrate-schemas if we know that we are currently testing. It's copied from django-tenant-schemas. --- hobo/multitenant/management/commands/migrate.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hobo/multitenant/management/commands/migrate.py b/hobo/multitenant/management/commands/migrate.py index a43849c..bc7abf3 100644 --- a/hobo/multitenant/management/commands/migrate.py +++ b/hobo/multitenant/management/commands/migrate.py @@ -6,6 +6,7 @@ import django from django.conf import settings from django.core.management.base import CommandError, BaseCommand +from tenant_schemas.utils import django_is_in_test_mode if django.VERSION < (1, 7, 0): try: @@ -25,3 +26,7 @@ class Command(MigrateCommand): "instead. Please read the documentation if you don't know why you " "shouldn't call migrate directly!".format(database)) super(Command, self).handle(*args, **options) + +if django.VERSION >= (1, 7, 0) and django_is_in_test_mode(): + from .migrate_schemas import MigrateSchemasCommand + Command = MigrateSchemasCommand -- 2.1.4