# Path: picatrix/lib/manager.py
# class Helper:
# class MagicManager:
#   MAGICS_DF_COLUMNS = ['name', 'description', 'line', 'cell', 'function']
#   def clear_helpers(cls):
#   def clear_magics(cls):
#   def deregister_helper(cls, helper_name: Text):
#   def deregister_magic(cls, magic_name: Text):
#   def get_helper(cls, helper_name: Text) -> Optional[Callable[..., Any]]:
#   def get_magic(cls, magic_name: Text) -> Callable[[Text, Text], Text]:
#   def get_helper_info(
#       cls,
#       as_pandas: Optional[bool] = True
#   ) -> Union[pandas.DataFrame, List[Tuple[Text, Text]]]:
#   def get_magic_info(
#       cls,
#       as_pandas: Optional[bool] = True
#   ) -> Union[pandas.DataFrame, List[Tuple[Text, Text]]]:
#   def register_helper(
#       cls, name: Text, helper: Any, typing_help: Dict[Text, Any]):
#   def register_magic(
#       cls,
#       function: Callable[[Text, Text], Text],
#       conditional: Callable[[], bool] = None):
#     def capture_output(function, name):
#       def wrapper(*args, **kwargs):
# 
# Path: picatrix/lib/utils.py
# def ask_question(question: Text, input_type: Optional[Any] = Text) -> Any:
# def clear_notebook_output():
# def ipython_bind_global(name: Text, value: Any) -> Any:
# def ipython_get_global(name: Text) -> Any:
# def ipython_remove_global(name: Text):


import typing
import mock
import pytest
from picatrix.lib import manager, utils
  assert not info_df[info_df.name == 'other_magic'].empty

  desc_set = set(info_df.description.unique())
  expected_set = set(
      [
          'Could this be it?', 'This is even more magic.',
          'This is a magical function that returns pure magic.'
      ])

  assert desc_set == expected_set

  entries = manager.MagicManager.get_magic_info(as_pandas=False)
  assert len(entries) == 3
  names = [x[0] for x in entries]
  assert 'other_magic' in names
  assert 'some_magic' in names


def test_helper_registration():
  """Test registering helpers."""

  def helper_func(stuff: typing.Text):
    """This is a helper function that helps."""
    back = f'{stuff}' * 3
    return f'{back}\n\nwasn\'t this helpful?'

  helper_dict = typing.get_type_hints(helper_func)
  manager.MagicManager.register_helper(
      name='helper_func', helper=helper_func, typing_help=helper_dict)


# Path: picatrix/lib/manager.py
# class Helper:
# class MagicManager:
#   MAGICS_DF_COLUMNS = ['name', 'description', 'line', 'cell', 'function']
#   def clear_helpers(cls):
#   def clear_magics(cls):
#   def deregister_helper(cls, helper_name: Text):
#   def deregister_magic(cls, magic_name: Text):
#   def get_helper(cls, helper_name: Text) -> Optional[Callable[..., Any]]:
#   def get_magic(cls, magic_name: Text) -> Callable[[Text, Text], Text]:
#   def get_helper_info(
#       cls,
#       as_pandas: Optional[bool] = True
#   ) -> Union[pandas.DataFrame, List[Tuple[Text, Text]]]:
#   def get_magic_info(
#       cls,
#       as_pandas: Optional[bool] = True
#   ) -> Union[pandas.DataFrame, List[Tuple[Text, Text]]]:
#   def register_helper(
#       cls, name: Text, helper: Any, typing_help: Dict[Text, Any]):
#   def register_magic(
#       cls,
#       function: Callable[[Text, Text], Text],
#       conditional: Callable[[], bool] = None):
#     def capture_output(function, name):
#       def wrapper(*args, **kwargs):
# 
# Path: picatrix/lib/utils.py
# def ask_question(question: Text, input_type: Optional[Any] = Text) -> Any:
# def clear_notebook_output():
# def ipython_bind_global(name: Text, value: Any) -> Any:
# def ipython_get_global(name: Text) -> Any:
# def ipython_remove_global(name: Text):


# Path: picatrix/lib/manager_test.py
import typing
import mock
import pytest
from picatrix.lib import manager, utils

  assert not info_df[info_df.name == 'other_magic'].empty

  desc_set = set(info_df.description.unique())
  expected_set = set(
      [
          'Could this be it?', 'This is even more magic.',
          'This is a magical function that returns pure magic.'
      ])

  assert desc_set == expected_set

  entries = manager.MagicManager.get_magic_info(as_pandas=False)
  assert len(entries) == 3
  names = [x[0] for x in entries]
  assert 'other_magic' in names
  assert 'some_magic' in names


def test_helper_registration():
  """Test registering helpers."""

  def helper_func(stuff: typing.Text):
    """This is a helper function that helps."""
    back = f'{stuff}' * 3
    return f'{back}\n\nwasn\'t this helpful?'

  helper_dict = typing.get_type_hints(helper_func)
  manager.MagicManager.register_helper(
      name='helper_func', helper=helper_func, typing_help=helper_dict)


  df = manager.MagicManager.get_helper_info()