当前位置: 首页>>代码示例>>Python>>正文


Python signals.post_migrate方法代码示例

本文整理汇总了Python中django.db.models.signals.post_migrate方法的典型用法代码示例。如果您正苦于以下问题:Python signals.post_migrate方法的具体用法?Python signals.post_migrate怎么用?Python signals.post_migrate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.db.models.signals的用法示例。


在下文中一共展示了signals.post_migrate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_args

# 需要导入模块: from django.db.models import signals [as 别名]
# 或者: from django.db.models.signals import post_migrate [as 别名]
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) 
开发者ID:denisenkom,项目名称:django-sqlserver,代码行数:20,代码来源:tests.py

示例2: test_args

# 需要导入模块: from django.db.models import signals [as 别名]
# 或者: from django.db.models.signals import post_migrate [as 别名]
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) 
开发者ID:nesdis,项目名称:djongo,代码行数:20,代码来源:tests.py

示例3: test_migrations_only

# 需要导入模块: from django.db.models import signals [as 别名]
# 或者: from django.db.models.signals import post_migrate [as 别名]
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']
        ) 
开发者ID:denisenkom,项目名称:django-sqlserver,代码行数:45,代码来源:tests.py

示例4: test_migrations_only

# 需要导入模块: from django.db.models import signals [as 别名]
# 或者: from django.db.models.signals import post_migrate [as 别名]
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']
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:45,代码来源:tests.py


注:本文中的django.db.models.signals.post_migrate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。