code: def test_get_planned_migrations(
      previous_migrations: list[Migration],
      collected_migrations: list[Migration],
      executed_migrations: list[Migration],
      exception: Optional[type[Exception]],
  ) -> None:
      for migration in previous_migrations:
          DatabaseMigration(
              version=migration.version,
              description=migration.description,
          ).save()
      assert DatabaseMigration.objects.distinct("version") == [
          migration.version for migration in previous_migrations
      ]
      plan = Plan(collected_migrations=collected_migrations)
      assert plan.executed_migrations == []
      if exception is None:
          # up worked
          plan.apply()
      else:
          # up failed
          with pytest.raises(exception):
              plan.apply()
      assert plan.executed_migrations == executed_migrations
      assert DatabaseMigration.objects.distinct("version") == [
          migration.version
          for migration in (previous_migrations + executed_migrations)
      ]
  
imports: from collections.abc import Iterator
  from typing import Optional
  import pytest
  from mongodb_migration.database_migrations import DatabaseMigration, _clean_maintenance_database
  from mongodb_migration.migration import IrreversibleMigrationError, Migration
  from mongodb_migration.plan import Plan, SavedMigrationsError
  from mongodb_migration.resources import MigrationsMongoResource
label_desc: Use image node_id 5 for calling a global function with example usage: test_get_planned_migrations(previous_migrations, collected_migrations, executed_migrations, exception) without return types