Repository: django/django
File: tests/migrations/test_autodetector.py (Python)

Code before:
            ModelState(
                "testapp",
                "Author",
                [
                    ("id", models.AutoField(primary_key=True)),
                    ("readings", models.ManyToManyField("testapp.Magazine")),
                ],
            ),
        ]

        changes = self.get_changes(before, after)

        self.assertNumberMigrations(changes, "testapp", 1)

        self.assertOperationTypes(changes, "testapp", 0, ["RemoveField", "AddField"])

        self.assertOperationAttributes(
            changes,
            "testapp",
            0,
            0,
            name="readings",
            model_name="author",
        )

        self.assertOperationAttributes(
            changes,
            "testapp",
            0,
            1,
            name="readings",
            model_name="author",
        )


class MigrationSuggestNameTests(SimpleTestCase):
    def test_no_operations(self):
        class Migration(migrations.Migration):
            operations = []

        migration = Migration("some_migration", "test_app")
        self.assertIs(migration.suggest_name().startswith("auto_"), True)

    def test_no_operations_initial(self):
        class Migration(migrations.Migration):
            initial = True
            operations = []

        migration = Migration("some_migration", "test_app")
        self.assertEqual(migration.suggest_name(), "initial")


Review comment (security):
Nit: I'd remove the blank lines; the file is already too long as it is 
```suggestion
        changes = self.get_changes(before, after)
        self.assertNumberMigrations(changes, "testapp", 1)
        self.assertOperationTypes(changes, "testapp", 0, ["RemoveField", "AddField"])
        self.assertOperationAttributes(
            changes,
            "testapp",
            0,
            0,
            name="readings",
            model_name="author",
        )
        self.assertOperationAttributes(
```

Code after:
            model_name="foo",
        )
        self.assertOperationAttributes(
            changes,
            "app",
            0,
            1,
            name="id",
            model_name="foo",
            preserve_default=True,
        )


class MigrationSuggestNameTests(SimpleTestCase):
    def test_no_operations(self):
        class Migration(migrations.Migration):
            operations = []

        migration = Migration("some_migration", "test_app")
        self.assertIs(migration.suggest_name().startswith("auto_"), True)

    def test_no_operations_initial(self):
        class Migration(migrations.Migration):
            initial = True
            operations = []

        migration = Migration("some_migration", "test_app")
        self.assertEqual(migration.suggest_name(), "initial")

    def test_single_operation(self):
        class Migration(migrations.Migration):
            operations = [migrations.CreateModel("Person", fields=[])]

        migration = Migration("0001_initial", "test_app")
        self.assertEqual(migration.suggest_name(), "person")

        class Migration(migrations.Migration):
            operations = [migrations.DeleteModel("Person")]

        migration = Migration("0002_initial", "test_app")
        self.assertEqual(migration.suggest_name(), "delete_person")

    def test_single_operation_long_name(self):
        class Migration(migrations.Migration):
            operations = [migrations.CreateModel("A" * 53, fields=[])]

        migration = Migration("some_migration", "test_app")
        self.assertEqual(migration.suggest_name(), "a" * 53)

    def test_two_operations(self):
        class Migration(migrations.Migration):