def METHOD_NAME(state_name):
    """
    Test - latest_active when a new kernel is available
    """
    reboot = MagicMock(return_value=True)
    latest = MagicMock(return_value=1)
    with patch.dict(
        kernelpkg.__salt__,
        {"kernelpkg.needs_reboot": reboot, "kernelpkg.latest_installed": latest},
    ), patch.dict(kernelpkg.__opts__, {"test": False}):
        kernelpkg.__salt__["system.reboot"].reset_mock()
        ret = kernelpkg.latest_active(name=state_name)
        assert ret["name"] == state_name
        assert ret["result"]
        assert isinstance(ret["changes"], dict)
        assert isinstance(ret["comment"], str)
        kernelpkg.__salt__["system.reboot"].assert_called_once()
        with patch.dict(kernelpkg.__opts__, {"test": True}):
            kernelpkg.__salt__["system.reboot"].reset_mock()
            ret = kernelpkg.latest_active(name=state_name)
            assert ret["name"] == state_name
            assert ret["result"] is None
            assert ret["changes"] == {"kernel": {"new": 1, "old": 0}}
            assert isinstance(ret["comment"], str)
            kernelpkg.__salt__["system.reboot"].assert_not_called()