Ticket #24725: 24725-test.diff

File 24725-test.diff, 1.7 KB (added by Tim Graham, 10 years ago)
  • tests/migrations/test_operations.py

    diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
    index b8354f3..353daf7 100644
    a b class OperationTests(OperationTestBase):  
    614614        self.assertEqual(Rider.objects.count(), 2)
    615615        self.assertEqual(Pony._meta.get_field('riders').remote_field.through.objects.count(), 2)
    616616
     617    def test_rename_m2m_target_model(self):
     618        app_label = "test_rename_m2m_target_model"
     619        project_state = self.apply_operations(app_label, ProjectState(), operations=[
     620            migrations.CreateModel("Rider", fields=[]),
     621            migrations.CreateModel("Pony", fields=[
     622                ("riders", models.ManyToManyField("Rider")),
     623            ]),
     624        ])
     625#        Pony = project_state.apps.get_model(app_label, "Pony")
     626#        Rider = project_state.apps.get_model(app_label, "Rider")
     627#        pony = Pony.objects.create()
     628#        rider = Rider.objects.create()
     629#        pony.riders.add(rider)
     630
     631        project_state = self.apply_operations(app_label, project_state, operations=[
     632            migrations.RenameModel("Rider", "Rider2"),
     633        ])
     634#        Pony = project_state.apps.get_model(app_label, "Pony2")
     635#        Rider = project_state.apps.get_model(app_label, "Rider")
     636#        pony = Pony.objects.create()
     637#        rider = Rider.objects.create()
     638#        pony.riders.add(rider)
     639#        self.assertEqual(Pony.objects.count(), 2)
     640#        self.assertEqual(Rider.objects.count(), 2)
     641#        self.assertEqual(Pony._meta.get_field('riders').remote_field.through.objects.count(), 2)
     642
    617643    def test_add_field(self):
    618644        """
    619645        Tests the AddField operation.
Back to Top