本文整理汇总了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)
示例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)
示例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']
)
示例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']
)