code: def test_migrate_role(
      description,
      new_pvms,
      pvm_map,
      external_pvms,
      deleted_views,
      deleted_permissions,
  ):
      """
      Permission migration: generic tests
      """
      logger.info(description)
      with create_old_role(pvm_map, external_pvms) as old_role:
          role_name = old_role.name
          session = db.session
  
          # Run migrations
          add_pvms(session, new_pvms)
          migrate_roles(session, pvm_map)
  
          role = (
              db.session.query(Role)
              .filter(Role.name == role_name)
              .one_or_none()
          )
          for old_pvm, new_pvms in pvm_map.items():
              old_pvm_model = (
                  security_manager.find_permission_view_menu(
                      old_pvm.permission, old_pvm.view
                  )
              )
              assert old_pvm_model is None
              new_pvm_model = (
                  security_manager.find_permission_view_menu(
                      new_pvms[0].permission, new_pvms[0].view
                  )
              )
              assert new_pvm_model is not None
              assert new_pvm_model in role.permissions
          # assert deleted view menus
          for deleted_view in deleted_views:
              assert (
                  security_manager.find_view_menu(deleted_view) is None
              )
          # assert deleted permissions
          for deleted_permission in deleted_permissions:
              assert (
                  security_manager.find_permission(deleted_permission)
                  is None
              )
          # assert externals are still there
          for external_pvm in external_pvms:
              assert (
                  security_manager.find_permission_view_menu(
                      external_pvm.permission, external_pvm.view
                  )
                  is not None
              )
  
file_path: superset/tests/integration_tests/security/migrate_roles_tests.py
imports: import logging
  from contextlib import contextmanager
  from unittest.mock import patch
  import pytest
  from flask_appbuilder.security.sqla.models import Role
  from superset.extensions import db, security_manager
  from superset.migrations.shared.security_converge import add_pvms, migrate_roles, Pvm, PvmMigrationMapType
  from tests.integration_tests.test_app import app
label_desc: Use image node_id 2 for calling a global function with example usage: test_migrate_role(description, new_pvms, pvm_map, external_pvms, deleted_views, deleted_permissions) without return types