def test_signal(self): """ #23641 - Sending the ``post_migrate`` signal triggers creation of the default site. """ post_migrate.send(sender=self.app_config, app_config=self.app_config, verbosity=0) self.assertTrue(Site.objects.exists())
def _trigger_signal(self): post_migrate.send( sender=self.appconfig, app_config=self.appconfig, verbosity=1, interactive=True, using='default')
def setUp(self): from django.db.models.signals import post_save, post_delete, post_migrate from django_elasticsearch.models import es_save_callback, es_delete_callback, es_syncdb_callback from django.apps import apps app = apps.get_app_config('django_elasticsearch') post_save.connect(es_save_callback) post_delete.connect(es_delete_callback) post_migrate.connect(es_syncdb_callback) if int(get_version()[2]) >= 6: sender = app else: sender = None post_migrate.send(sender=sender, app_config=app, created_models=[ TestModel, ], verbosity=2) self.instance = TestModel.objects.create(username=u"1", first_name=u"woot", last_name=u"foo") self.instance.es.do_index()
def setUp(self): from django.db.models.signals import post_save, post_delete try: from django.db.models.signals import post_migrate except ImportError: # django <= 1.6 from django.db.models.signals import post_syncdb as post_migrate from django_elasticsearch.models import es_save_callback from django_elasticsearch.models import es_delete_callback from django_elasticsearch.models import es_syncdb_callback try: from django.apps import apps app = apps.get_app_config('django_elasticsearch') except ImportError: # django 1.4 from django.db.models import get_app app = get_app('django_elasticsearch') post_save.connect(es_save_callback) post_delete.connect(es_delete_callback) post_migrate.connect(es_syncdb_callback) if int(get_version()[2]) >= 6: sender = app else: sender = None post_migrate.send(sender=sender, app_config=app, app=app, # django 1.4 created_models=[TestModel,], verbosity=2) self.instance = TestModel.objects.create(username=u"1", first_name=u"woot", last_name=u"foo") self.instance.es.do_index()
def finish_previous_migrations(migrate_apps): """ Explicitly run the post_migrate actions for all apps """ for app_config in apps.get_app_configs(): post_migrate.send(sender=app_config, app_config=app_config, verbosity=0)
def test_create_default_site_signal(self): """ Checks that sending ``post_migrate`` creates the default site. """ Site.objects.all().delete() app_config = apps.get_app_config('sites') post_migrate.send(sender=app_config, app_config=app_config, verbosity=0) self.assertTrue(Site.objects.exists())
def emit_post_migrate_signal(verbosity, interactive, db): # Emit the post_migrate signal for every application. for app_config in apps.get_app_configs(): if app_config.models_module is None: continue if verbosity >= 2: print("Running post-migrate handlers for application %s" % app_config.label) post_migrate.send( sender=app_config, app_config=app_config, verbosity=verbosity, interactive=interactive, using=db)
def test_post_migrate_populate_notification_settings( self, mocked_task, *args): with patch.object(app_settings, 'POPULATE_PREFERENCES_ON_MIGRATE', False): NotificationAppConfig.ready() post_migrate.send(sender=NotificationAppConfig, app_config=NotificationAppConfig) mocked_task.assert_not_called() with patch.object(app_settings, 'POPULATE_PREFERENCES_ON_MIGRATE', True): NotificationAppConfig.ready() post_migrate.send(sender=NotificationAppConfig, app_config=NotificationAppConfig) mocked_task.assert_called_once()
def handle(self, *args, **kwargs): from django.db.models.signals import post_migrate from django.db import DEFAULT_DB_ALIAS from tendenci.apps.notifications import models as notifications tuples = post_migrate.send( sender=notifications, app_config=notifications, verbosity=0, interactive=True, using=DEFAULT_DB_ALIAS, ) for t in tuples: print('post_migrate handler', t[0])
def test_post_migrate_handler_celery_broker_unreachable(self, mocked_logger, *args): post_migrate.send( sender=NotificationsAppConfig, app_config=NotificationsAppConfig ) mocked_logger.assert_called_once()