import pytest
from nesta.packages.misc_utils.guess_sql_type import guess_sql_type

@pytest.fixture
def int_data():
    return [1,2,4,False]

@pytest.fixture
def text_data():
    return ['a', True, 2, 
            ('A very long sentence A very long sentence A '
             'very long sentence A very long sentence'), 'd']

@pytest.fixture
def float_data():
    return [1,2.3,True,None]

@pytest.fixture
def bool_data():
    return [True,False,None]


def test_guess_sql_type_int(int_data):
    assert guess_sql_type(int_data) == 'INTEGER'

def test_guess_sql_type_float(float_data):
    assert guess_sql_type(float_data) == 'FLOAT'

def test_guess_sql_type_bool(bool_data):
    assert guess_sql_type(bool_data) == 'BOOLEAN'

def test_guess_sql_type_str(text_data):
    assert guess_sql_type(text_data, text_len=10) == 'TEXT'
    assert guess_sql_type(text_data, text_len=100).startswith('VARCHAR(')

[((24, 11, 24, 35), 'nesta.packages.misc_utils.guess_sql_type.guess_sql_type', 'guess_sql_type', ({(24, 26, 24, 34): 'int_data'}, {}), '(int_data)', False, 'from nesta.packages.misc_utils.guess_sql_type import guess_sql_type\n'), ((27, 11, 27, 37), 'nesta.packages.misc_utils.guess_sql_type.guess_sql_type', 'guess_sql_type', ({(27, 26, 27, 36): 'float_data'}, {}), '(float_data)', False, 'from nesta.packages.misc_utils.guess_sql_type import guess_sql_type\n'), ((30, 11, 30, 36), 'nesta.packages.misc_utils.guess_sql_type.guess_sql_type', 'guess_sql_type', ({(30, 26, 30, 35): 'bool_data'}, {}), '(bool_data)', False, 'from nesta.packages.misc_utils.guess_sql_type import guess_sql_type\n'), ((33, 11, 33, 49), 'nesta.packages.misc_utils.guess_sql_type.guess_sql_type', 'guess_sql_type', (), '', False, 'from nesta.packages.misc_utils.guess_sql_type import guess_sql_type\n'), ((34, 11, 34, 50), 'nesta.packages.misc_utils.guess_sql_type.guess_sql_type', 'guess_sql_type', (), '', False, 'from nesta.packages.misc_utils.guess_sql_type import guess_sql_type\n')]