import _ast

from peon.src.project.file.function_def.function import FunctionLint


class ReflectionAtLineFixture:
    empty_node = _ast.Pass
    is_instance_at_first_lvl = _ast.FunctionDef(id='isinstance', lineno=1)
    type_at_first_lvl = _ast.FunctionDef(id='type', lineno=1)
    is_instance_at_second_lvl = _ast.FunctionDef(body=[_ast.Expr(id='isinstance', lineno=2)], lineno=1)
    type_at_second_lvl = _ast.FunctionDef(body=[_ast.Expr(id='type', lineno=2)], lineno=1)


def test_empty_node():
    assert FunctionLint(
        definition=ReflectionAtLineFixture.empty_node,
    ).reflection_at_line() == tuple()


def test_is_instance_at_first_lvl():
    assert FunctionLint(
        definition=ReflectionAtLineFixture.is_instance_at_first_lvl,
    ).reflection_at_line() == (1,)


def test_type_at_first_lvl():
    assert FunctionLint(
        definition=ReflectionAtLineFixture.type_at_first_lvl,
    ).reflection_at_line() == (1,)


def test_is_instance_at_second_lvl():
    assert FunctionLint(
        definition=ReflectionAtLineFixture.is_instance_at_second_lvl,
    ).reflection_at_line() == (2,)


def test_type_at_second_lvl():
    assert FunctionLint(
        definition=ReflectionAtLineFixture.type_at_second_lvl,
    ).reflection_at_line() == (2,)

[((173, 216), '_ast.FunctionDef', '_ast.FunctionDef', ([], {'id': '"""isinstance"""', 'lineno': '(1)'}), "(id='isinstance', lineno=1)\n", (189, 216), False, 'import _ast\n'), ((241, 278), '_ast.FunctionDef', '_ast.FunctionDef', ([], {'id': '"""type"""', 'lineno': '(1)'}), "(id='type', lineno=1)\n", (257, 278), False, 'import _ast\n'), ((334, 370), '_ast.Expr', '_ast.Expr', ([], {'id': '"""isinstance"""', 'lineno': '(2)'}), "(id='isinstance', lineno=2)\n", (343, 370), False, 'import _ast\n'), ((431, 461), '_ast.Expr', '_ast.Expr', ([], {'id': '"""type"""', 'lineno': '(2)'}), "(id='type', lineno=2)\n", (440, 461), False, 'import _ast\n'), ((510, 569), 'peon.src.project.file.function_def.function.FunctionLint', 'FunctionLint', ([], {'definition': 'ReflectionAtLineFixture.empty_node'}), '(definition=ReflectionAtLineFixture.empty_node)\n', (522, 569), False, 'from peon.src.project.file.function_def.function import FunctionLint\n'), ((667, 740), 'peon.src.project.file.function_def.function.FunctionLint', 'FunctionLint', ([], {'definition': 'ReflectionAtLineFixture.is_instance_at_first_lvl'}), '(definition=ReflectionAtLineFixture.is_instance_at_first_lvl)\n', (679, 740), False, 'from peon.src.project.file.function_def.function import FunctionLint\n'), ((828, 894), 'peon.src.project.file.function_def.function.FunctionLint', 'FunctionLint', ([], {'definition': 'ReflectionAtLineFixture.type_at_first_lvl'}), '(definition=ReflectionAtLineFixture.type_at_first_lvl)\n', (840, 894), False, 'from peon.src.project.file.function_def.function import FunctionLint\n'), ((990, 1064), 'peon.src.project.file.function_def.function.FunctionLint', 'FunctionLint', ([], {'definition': 'ReflectionAtLineFixture.is_instance_at_second_lvl'}), '(definition=ReflectionAtLineFixture.is_instance_at_second_lvl)\n', (1002, 1064), False, 'from peon.src.project.file.function_def.function import FunctionLint\n'), ((1153, 1220), 'peon.src.project.file.function_def.function.FunctionLint', 'FunctionLint', ([], {'definition': 'ReflectionAtLineFixture.type_at_second_lvl'}), '(definition=ReflectionAtLineFixture.type_at_second_lvl)\n', (1165, 1220), False, 'from peon.src.project.file.function_def.function import FunctionLint\n')]