Python django.db.models.signals.post_migrate() Examples

The following are 6 code examples of django.db.models.signals.post_migrate(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.db.models.signals , or try the search function .
Example #1
Source File: tests.py    From django-sqlserver with MIT License 6 votes vote down vote up
def test_args(self):
        pre_migrate_receiver = Receiver(signals.pre_migrate)
        post_migrate_receiver = Receiver(signals.post_migrate)
        management.call_command(
            'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
            interactive=MIGRATE_INTERACTIVE, stdout=six.StringIO(),
        )

        for receiver in [pre_migrate_receiver, post_migrate_receiver]:
            args = receiver.call_args
            self.assertEqual(receiver.call_counter, 1)
            self.assertEqual(set(args), set(SIGNAL_ARGS))
            self.assertEqual(args['app_config'], APP_CONFIG)
            self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
            self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
            self.assertEqual(args['using'], 'default')
            self.assertEqual(args['plan'], [])
            self.assertIsInstance(args['apps'], migrations.state.StateApps) 
Example #2
Source File: tests.py    From djongo with GNU Affero General Public License v3.0 6 votes vote down vote up
def test_args(self):
        pre_migrate_receiver = Receiver(signals.pre_migrate)
        post_migrate_receiver = Receiver(signals.post_migrate)
        management.call_command(
            'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
            interactive=MIGRATE_INTERACTIVE, stdout=StringIO(),
        )

        for receiver in [pre_migrate_receiver, post_migrate_receiver]:
            args = receiver.call_args
            self.assertEqual(receiver.call_counter, 1)
            self.assertEqual(set(args), set(SIGNAL_ARGS))
            self.assertEqual(args['app_config'], APP_CONFIG)
            self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
            self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
            self.assertEqual(args['using'], 'default')
            self.assertEqual(args['plan'], [])
            self.assertIsInstance(args['apps'], migrations.state.StateApps) 
Example #3
Source File: tests.py    From djongo with GNU Affero General Public License v3.0 6 votes vote down vote up
def test_args(self):
        pre_migrate_receiver = Receiver(signals.pre_migrate)
        post_migrate_receiver = Receiver(signals.post_migrate)
        management.call_command(
            'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
            interactive=MIGRATE_INTERACTIVE, stdout=StringIO(),
        )

        for receiver in [pre_migrate_receiver, post_migrate_receiver]:
            args = receiver.call_args
            self.assertEqual(receiver.call_counter, 1)
            self.assertEqual(set(args), set(SIGNAL_ARGS))
            self.assertEqual(args['app_config'], APP_CONFIG)
            self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
            self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
            self.assertEqual(args['using'], 'default')
            self.assertEqual(args['plan'], [])
            self.assertIsInstance(args['apps'], migrations.state.StateApps) 
Example #4
Source File: tests.py    From django-sqlserver with MIT License 4 votes vote down vote up
def test_migrations_only(self):
        """
        If all apps have migrations, migration signals should be sent.
        """
        pre_migrate_receiver = Receiver(signals.pre_migrate)
        post_migrate_receiver = Receiver(signals.post_migrate)
        stdout = six.StringIO()
        management.call_command(
            'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
            interactive=MIGRATE_INTERACTIVE, stdout=stdout,
        )
        for receiver in [pre_migrate_receiver, post_migrate_receiver]:
            args = receiver.call_args
            self.assertEqual(receiver.call_counter, 1)
            self.assertEqual(set(args), set(SIGNAL_ARGS))
            self.assertEqual(args['app_config'], APP_CONFIG)
            self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
            self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
            self.assertEqual(args['using'], 'default')
            self.assertIsInstance(args['plan'][0][0], migrations.Migration)
            # The migration isn't applied backward.
            self.assertFalse(args['plan'][0][1])
            self.assertIsInstance(args['apps'], migrations.state.StateApps)
        self.assertEqual(pre_migrate_receiver.call_args['apps'].get_models(), [])
        self.assertEqual(
            [model._meta.label for model in post_migrate_receiver.call_args['apps'].get_models()],
            ['migrate_signals.Signal']
        )
        # Migrating with an empty plan.
        pre_migrate_receiver = Receiver(signals.pre_migrate)
        post_migrate_receiver = Receiver(signals.post_migrate)
        management.call_command(
            'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
            interactive=MIGRATE_INTERACTIVE, stdout=stdout,
        )
        self.assertEqual(
            [model._meta.label for model in pre_migrate_receiver.call_args['apps'].get_models()],
            ['migrate_signals.Signal']
        )
        self.assertEqual(
            [model._meta.label for model in post_migrate_receiver.call_args['apps'].get_models()],
            ['migrate_signals.Signal']
        ) 
Example #5
Source File: tests.py    From djongo with GNU Affero General Public License v3.0 4 votes vote down vote up
def test_migrations_only(self):
        """
        If all apps have migrations, migration signals should be sent.
        """
        pre_migrate_receiver = Receiver(signals.pre_migrate)
        post_migrate_receiver = Receiver(signals.post_migrate)
        stdout = StringIO()
        management.call_command(
            'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
            interactive=MIGRATE_INTERACTIVE, stdout=stdout,
        )
        for receiver in [pre_migrate_receiver, post_migrate_receiver]:
            args = receiver.call_args
            self.assertEqual(receiver.call_counter, 1)
            self.assertEqual(set(args), set(SIGNAL_ARGS))
            self.assertEqual(args['app_config'], APP_CONFIG)
            self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
            self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
            self.assertEqual(args['using'], 'default')
            self.assertIsInstance(args['plan'][0][0], migrations.Migration)
            # The migration isn't applied backward.
            self.assertFalse(args['plan'][0][1])
            self.assertIsInstance(args['apps'], migrations.state.StateApps)
        self.assertEqual(pre_migrate_receiver.call_args['apps'].get_models(), [])
        self.assertEqual(
            [model._meta.label for model in post_migrate_receiver.call_args['apps'].get_models()],
            ['migrate_signals.Signal']
        )
        # Migrating with an empty plan.
        pre_migrate_receiver = Receiver(signals.pre_migrate)
        post_migrate_receiver = Receiver(signals.post_migrate)
        management.call_command(
            'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
            interactive=MIGRATE_INTERACTIVE, stdout=stdout,
        )
        self.assertEqual(
            [model._meta.label for model in pre_migrate_receiver.call_args['apps'].get_models()],
            ['migrate_signals.Signal']
        )
        self.assertEqual(
            [model._meta.label for model in post_migrate_receiver.call_args['apps'].get_models()],
            ['migrate_signals.Signal']
        ) 
Example #6
Source File: tests.py    From djongo with GNU Affero General Public License v3.0 4 votes vote down vote up
def test_migrations_only(self):
        """
        If all apps have migrations, migration signals should be sent.
        """
        pre_migrate_receiver = Receiver(signals.pre_migrate)
        post_migrate_receiver = Receiver(signals.post_migrate)
        stdout = StringIO()
        management.call_command(
            'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
            interactive=MIGRATE_INTERACTIVE, stdout=stdout,
        )
        for receiver in [pre_migrate_receiver, post_migrate_receiver]:
            args = receiver.call_args
            self.assertEqual(receiver.call_counter, 1)
            self.assertEqual(set(args), set(SIGNAL_ARGS))
            self.assertEqual(args['app_config'], APP_CONFIG)
            self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
            self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
            self.assertEqual(args['using'], 'default')
            self.assertIsInstance(args['plan'][0][0], migrations.Migration)
            # The migration isn't applied backward.
            self.assertFalse(args['plan'][0][1])
            self.assertIsInstance(args['apps'], migrations.state.StateApps)
        self.assertEqual(pre_migrate_receiver.call_args['apps'].get_models(), [])
        self.assertEqual(
            [model._meta.label for model in post_migrate_receiver.call_args['apps'].get_models()],
            ['migrate_signals.Signal']
        )
        # Migrating with an empty plan.
        pre_migrate_receiver = Receiver(signals.pre_migrate)
        post_migrate_receiver = Receiver(signals.post_migrate)
        management.call_command(
            'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
            interactive=MIGRATE_INTERACTIVE, stdout=stdout,
        )
        self.assertEqual(
            [model._meta.label for model in pre_migrate_receiver.call_args['apps'].get_models()],
            ['migrate_signals.Signal']
        )
        self.assertEqual(
            [model._meta.label for model in post_migrate_receiver.call_args['apps'].get_models()],
            ['migrate_signals.Signal']
        )