"""
Test to check for use of the pandas soon-to-be-deprecated `.read_table()`
method.
"""
import ast

from pandas_vet import PD012, VetPlugin


def test_PD012_pass_read_csv():
    """
    Test that using .read_csv() explicitly does not result in an error.
    """
    statement = "employees = pd.read_csv(input_file)"
    tree = ast.parse(statement)
    actual = list(VetPlugin(tree).run())
    expected = []
    assert actual == expected


def test_PD012_fail_read_table():
    """
    Test that using .read_table() method results in an error.
    """
    statement = "employees = pd.read_table(input_file)"
    tree = ast.parse(statement)
    actual = list(VetPlugin(tree).run())
    expected = [PD012(1, 12)]
    assert actual == expected


def test_PD012_node_Name_pass():
    """
    Test that where 'read_table' is a Name does NOT raise an error
    """
    statement = "employees = read_table"
    tree = ast.parse(statement)
    actual = list(VetPlugin(tree).run())
    expected = []
    assert actual == expected
