def test_missing_get_model_import(self):
        def incorrect_importing_model_forward(apps, schema_editor):
            from tests.test_project.app_data_migrations.models import MyModel

            MyModel.objects.filter(id=1).first()

        issues = MigrationLinter.get_runpython_model_import_issues(
            incorrect_importing_model_forward)
        self.assertEqual(1, len(issues))
    def test_correct_one_param_get_model_import(self):
        def forward_method(apps, schema_editor):
            User = apps.get_model("auth.User")

            User.objects.filter(id=1).first()

        issues = MigrationLinter.get_runpython_model_import_issues(
            forward_method)
        self.assertEqual(0, len(issues))
    def test_not_overlapping_model_name(self):
        """
        Correct for the import error, but should raise a warning
        """
        def forward_method(apps, schema_editor):
            User = apps.get_model("auth", "CustomUserModel")

            User.objects.filter(id=1).first()

        issues = MigrationLinter.get_runpython_model_import_issues(
            forward_method)
        self.assertEqual(0, len(issues))
    def test_correct_get_model_import(self):
        def correct_importing_model_forward(apps, schema_editor):
            MyModel = apps.get_model("app_data_migrations", "MyModel")
            MyVeryLongLongLongModel = apps.get_model(
                "app_data_migrations", "MyVeryLongLongLongModel")
            MultiLineModel = apps.get_model(
                "app_data_migrations",
                "MultiLineModel",
            )

            MyModel.objects.filter(id=1).first()
            MyVeryLongLongLongModel.objects.filter(id=1).first()
            MultiLineModel.objects.all()

        issues = MigrationLinter.get_runpython_model_import_issues(
            correct_importing_model_forward)
        self.assertEqual(0, len(issues))