import logging

from testing_func import testing_func, test_logger
from unit_parse import logger, Unit, Q
from unit_parse.utils import *

test_logger.setLevel(logging.DEBUG)
logger.setLevel(logging.DEBUG)


test_split_list = [
    # positive control (changes)
    [["fish","pig", "cow"], ["f", "is", "h", "pig", "cow"], {"chunks": ["is"]}],
    [["fish", Unit("g"), "cow"], ["f", "is", "h", Unit("g"), "cow"], {"chunks": ["is"]}],
    [["fishpigcow"], ["f", "i", "shpigcow"], {"chunks": ["i"]}],
    [["fishpigcow"], ["f", "i", "shpig", "c", "ow"], {"chunks": ["i", "c"]}],

    # negative control (no changes)
    [["fish"], ["fish"], {"chunks": ["fish"]}],
    [["fishpigcow"], ["fishpigcow"], {"chunks": ["z"]}],
    [[Unit("g")], [Unit("g")], {"chunks": ["is"]}],
]
testing_func(split_list, test_split_list)


test_round_off = [  # [Input, Output]
    # positive control (works)
    [234.2342300000001, 234.23423, {"sig_digit": 15}],
    [234.2342399999999999, 234.23424, {"sig_digit": 15}],
    [234.2342300000001, 234.23, {"sig_digit": 5}],
    [234.2342399999999999, 234.23, {"sig_digit": 5}],
    [234.2342399999999999, 200, {"sig_digit": 1}],
    [-234.2342399999999999, -200, {"sig_digit": 1}],
    [-234.2342399999999999, -234.23424, {"sig_digit": 15}],
    # negative control (fails)

]
testing_func(sig_figs, test_round_off)


test_list_depth = [  # [Input, Output]
    # positive control (works)
    ["", 0],
    [[], 0],
    ["asds", 0],
    [1, 0],
    [["aaa"], 1],
    [[["aaa"]], 2],
    [[["aaa", "aaa", "aaa"], ["aaa"], ["aaa"]], 2],
    [[["aaa", "aaa", "aaa"], ["aaa"], ["aaa"]], 2],
    [[[["aaa"], ["aaa"], ["aaa"]]], 3],

    # negative control (fails)

]
testing_func(get_list_depth, test_list_depth)


test_remove_empty_cells = [  # [Input, Output]
    # positive control (works)
    [[], None],
    [[""], None],
    [["asds"], ["asds"]],
    [1, 1],
    [["aaa", ""], ["aaa"]],
    [["aaa", []], ["aaa"]],
    [[["aaa", []]], [["aaa"]]],
    [[["aaa", [""]]], [["aaa"]]],

    # negative control (fails)

]
testing_func(remove_empty_cells, test_remove_empty_cells)


examples_quantity_difference = [
    [Q("5 g"), Q("0.5"), {"quantity2": Q("10 g")}],

    [5, 1, {"quantity2": Q("10 g")}],
]
testing_func(quantity_difference, examples_quantity_difference)


[((7, 0, 7, 35), 'testing_func.test_logger.setLevel', 'test_logger.setLevel', ({(7, 21, 7, 34): 'logging.DEBUG'}, {}), '(logging.DEBUG)', False, 'from testing_func import testing_func, test_logger\n'), ((8, 0, 8, 30), 'unit_parse.logger.setLevel', 'logger.setLevel', ({(8, 16, 8, 29): 'logging.DEBUG'}, {}), '(logging.DEBUG)', False, 'from unit_parse import logger, Unit, Q\n'), ((23, 0, 23, 41), 'testing_func.testing_func', 'testing_func', ({(23, 13, 23, 23): 'split_list', (23, 25, 23, 40): 'test_split_list'}, {}), '(split_list, test_split_list)', False, 'from testing_func import testing_func, test_logger\n'), ((38, 0, 38, 38), 'testing_func.testing_func', 'testing_func', ({(38, 13, 38, 21): 'sig_figs', (38, 23, 38, 37): 'test_round_off'}, {}), '(sig_figs, test_round_off)', False, 'from testing_func import testing_func, test_logger\n'), ((56, 0, 56, 45), 'testing_func.testing_func', 'testing_func', ({(56, 13, 56, 27): 'get_list_depth', (56, 29, 56, 44): 'test_list_depth'}, {}), '(get_list_depth, test_list_depth)', False, 'from testing_func import testing_func, test_logger\n'), ((73, 0, 73, 57), 'testing_func.testing_func', 'testing_func', ({(73, 13, 73, 31): 'remove_empty_cells', (73, 33, 73, 56): 'test_remove_empty_cells'}, {}), '(remove_empty_cells, test_remove_empty_cells)', False, 'from testing_func import testing_func, test_logger\n'), ((81, 0, 81, 63), 'testing_func.testing_func', 'testing_func', ({(81, 13, 81, 32): 'quantity_difference', (81, 34, 81, 62): 'examples_quantity_difference'}, {}), '(quantity_difference, examples_quantity_difference)', False, 'from testing_func import testing_func, test_logger\n'), ((77, 5, 77, 13), 'unit_parse.Q', 'Q', ({(77, 7, 77, 12): '"""5 g"""'}, {}), "('5 g')", False, 'from unit_parse import logger, Unit, Q\n'), ((77, 15, 77, 23), 'unit_parse.Q', 'Q', ({(77, 17, 77, 22): '"""0.5"""'}, {}), "('0.5')", False, 'from unit_parse import logger, Unit, Q\n'), ((14, 14, 14, 23), 'unit_parse.Unit', 'Unit', ({(14, 19, 14, 22): '"""g"""'}, {}), "('g')", False, 'from unit_parse import logger, Unit, Q\n'), ((14, 50, 14, 59), 'unit_parse.Unit', 'Unit', ({(14, 55, 14, 58): '"""g"""'}, {}), "('g')", False, 'from unit_parse import logger, Unit, Q\n'), ((21, 6, 21, 15), 'unit_parse.Unit', 'Unit', ({(21, 11, 21, 14): '"""g"""'}, {}), "('g')", False, 'from unit_parse import logger, Unit, Q\n'), ((21, 19, 21, 28), 'unit_parse.Unit', 'Unit', ({(21, 24, 21, 27): '"""g"""'}, {}), "('g')", False, 'from unit_parse import logger, Unit, Q\n'), ((77, 39, 77, 48), 'unit_parse.Q', 'Q', ({(77, 41, 77, 47): '"""10 g"""'}, {}), "('10 g')", False, 'from unit_parse import logger, Unit, Q\n'), ((79, 25, 79, 34), 'unit_parse.Q', 'Q', ({(79, 27, 79, 33): '"""10 g"""'}, {}), "('10 g')", False, 'from unit_parse import logger, Unit, Q\n')]