# Path: picatrix/lib/framework.py
# class MagicProtocol(Protocol):
# class MagicArgument:
# class MagicArgumentParser(argparse.ArgumentParser):
# class _Magic:
#   def __call__(self, *args: Any) -> Any:
#   def __init__(self, *argc, **kwargs):
#   def __init__(self, *args, **kwargs):
#   def exit(self, status: Optional[int] = 0, message: Optional[Text] = ''):
#   def __init__(
#       self,
#       fn: MagicProtocol,
#       arguments: Optional[List[MagicArgument]] = None,
#       name_func: Optional[Callable[[Text], Text]] = None):
#   def __call__(self, line: Text, cell: Optional[Text] = None) -> Optional[Any]:
#   def __dir__(self):
#   def __getattribute__(self, name: Text):
# def _get_arguments_from_arg_lines(
#     arg_lines: List[Text]) -> List[Dict[Text, Text]]:
# def _get_argument_lines_from_docstring(lines: List[Text]) -> List[Text]:
# def _add_function_arguments_to_parser(
#     fn: MagicProtocol, parser: MagicArgumentParser):
# def _parse_docstring(function: MagicProtocol) -> List[Dict[Text, Text]]:
# def _parse_line_string(line: Text) -> List[Text]:
# def picatrix_helper(function: Callable[..., Any]) -> Callable[..., Any]:
# def picatrix_magic(
#     function: Optional[MagicProtocol] = None,
#     arguments: Optional[List[MagicArgument]] = None,
#     name_func: Optional[Callable[[Text], Text]] = None,
#     conditional: Optional[Callable[[None], bool]] = None) -> MagicProtocol:
#   def wrapper(func):
# 
# 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/magics/common.py
# def picatrixhelpers(data: Optional[Text] = '') -> pandas.DataFrame:
# def picatrixmagics(data: Optional[Text] = '') -> pandas.DataFrame:
# def last_output(data: Optional[Text] = '') -> Any:


from typing import Optional, Text
from picatrix.lib import framework, manager
from picatrix.magics import common
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for the picatrix framework."""



def my_very_own_test_magic(data: Text, stuff: Optional[int] = 20) -> Text:
  """This is a magic that is used for testing.

    Args:
        data (str): This is a string.
        stuff (int): And this is a number.

    Returns:
        str: A string that combines the two parameters together.
  """
  return f'{data.strip()} - {stuff}'


def test_registration():
  """Test the magic decorator."""
  manager.MagicManager.clear_magics()
  _ = framework.picatrix_magic(my_very_own_test_magic)
  magic = framework.picatrix_magic(common.picatrixmagics)

  df = magic(line='')
  assert len(df) == 2

# Path: picatrix/lib/framework.py
# class MagicProtocol(Protocol):
# class MagicArgument:
# class MagicArgumentParser(argparse.ArgumentParser):
# class _Magic:
#   def __call__(self, *args: Any) -> Any:
#   def __init__(self, *argc, **kwargs):
#   def __init__(self, *args, **kwargs):
#   def exit(self, status: Optional[int] = 0, message: Optional[Text] = ''):
#   def __init__(
#       self,
#       fn: MagicProtocol,
#       arguments: Optional[List[MagicArgument]] = None,
#       name_func: Optional[Callable[[Text], Text]] = None):
#   def __call__(self, line: Text, cell: Optional[Text] = None) -> Optional[Any]:
#   def __dir__(self):
#   def __getattribute__(self, name: Text):
# def _get_arguments_from_arg_lines(
#     arg_lines: List[Text]) -> List[Dict[Text, Text]]:
# def _get_argument_lines_from_docstring(lines: List[Text]) -> List[Text]:
# def _add_function_arguments_to_parser(
#     fn: MagicProtocol, parser: MagicArgumentParser):
# def _parse_docstring(function: MagicProtocol) -> List[Dict[Text, Text]]:
# def _parse_line_string(line: Text) -> List[Text]:
# def picatrix_helper(function: Callable[..., Any]) -> Callable[..., Any]:
# def picatrix_magic(
#     function: Optional[MagicProtocol] = None,
#     arguments: Optional[List[MagicArgument]] = None,
#     name_func: Optional[Callable[[Text], Text]] = None,
#     conditional: Optional[Callable[[None], bool]] = None) -> MagicProtocol:
#   def wrapper(func):
# 
# 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/magics/common.py
# def picatrixhelpers(data: Optional[Text] = '') -> pandas.DataFrame:
# def picatrixmagics(data: Optional[Text] = '') -> pandas.DataFrame:
# def last_output(data: Optional[Text] = '') -> Any:


# Path: picatrix/magics/common_test.py
from typing import Optional, Text
from picatrix.lib import framework, manager
from picatrix.magics import common

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for the picatrix framework."""



def my_very_own_test_magic(data: Text, stuff: Optional[int] = 20) -> Text:
  """This is a magic that is used for testing.

    Args:
        data (str): This is a string.
        stuff (int): And this is a number.

    Returns:
        str: A string that combines the two parameters together.
  """
  return f'{data.strip()} - {stuff}'


def test_registration():
  """Test the magic decorator."""
  manager.MagicManager.clear_magics()
  _ = framework.picatrix_magic(my_very_own_test_magic)
  magic = framework.picatrix_magic(common.picatrixmagics)

  df = magic(line='')
  assert len(df) == 2

  assert set(df.columns) == set(manager.MagicManager.MAGICS_DF_COLUMNS)