import functions
from pytest import approx
from bcca.test import should_print


def test_add_em_up():
    assert functions.add_em_up(1, 2, 3) == 6
    assert functions.add_em_up(4, 5, 6) == 15


def test_sub_sub_hubbub():
    assert functions.sub_sub_hubbub(1, 2, 3) == -4


def test_square_area():
    assert functions.square_area(5, 5) == 25
    assert functions.square_area(3, 5) == 15
    assert functions.square_area(2, 2) == 4


def test_circle_area():
    assert functions.circle_area(1) == approx(3.14)
    assert functions.circle_area(5) == approx(78.5)


def test_kilometers_to_miles():
    assert functions.kilometers_to_miles(1) == approx(0.6214)
    assert functions.kilometers_to_miles(.5) == approx(0.3107)
    assert functions.kilometers_to_miles(0) == approx(0.0)
    assert functions.kilometers_to_miles(40) == approx(24.855999999999998)


@should_print
def test_sales_tax_1(output):
    functions.sales_tax(1)

    assert output == """
Purchase Amount: 1
State Sales Tax: 0.04
County Sales Tax: 0.02
Total Sales Tax: 0.06
Total Cost: 1.06
"""


@should_print
def test_sales_tax_99_99(output):
    functions.sales_tax(99.99)

    assert output == """
Purchase Amount: 99.99
State Sales Tax: 3.9996
County Sales Tax: 1.9998
Total Sales Tax: 5.9994
Total Cost: 105.98939999999999
"""


@should_print
def test_sales_tax_5_95(output):
    functions.sales_tax(5.95)

    assert output == """
Purchase Amount: 5.95
State Sales Tax: 0.23800000000000002
County Sales Tax: 0.11900000000000001
Total Sales Tax: 0.35700000000000004
Total Cost: 6.307
"""


def test_min_insurance():
    assert functions.min_insurance(100000) == approx(80000.0)
    assert functions.min_insurance(123456789) == approx(98765431.2)
    assert functions.min_insurance(0) == approx(0.0)
    assert functions.min_insurance(-54317890) == approx(-43454312.0)


@should_print
def test_property_tax_10000(output):
    functions.property_tax(10000)

    assert output == '''
Assessment Value: 6000.0
Property Tax: 38.4
'''


@should_print
def test_property_tax_99999_95(output):
    functions.property_tax(99999.95)

    assert output == '''
Assessment Value: 59999.969999999994
Property Tax: 383.999808
'''


def test_bmi():
    assert functions.bmi(160, 67) == approx(25.05680552)
    assert functions.bmi(200, 72) == approx(27.12191358)
    assert functions.bmi(120, 60) == approx(23.43333333)


def test_calories():
    assert functions.calories(5, 20) == 125
    assert functions.calories(1, 1) == 13


def test_earnings():
    assert functions.earnings(100, 100, 100) == 3600
    assert functions.earnings(50, 75, 100) == 2550
    assert functions.earnings(0, 1000, 79) == 12711


@should_print
def test_paint_job_estimator(output):
    functions.paint_job_estimator(50, 10)

    assert output == '''
Gallons of paint required: 0.43478260869565216
Hours of labor required: 3.4782608695652173
Cost of paint: 4.3478260869565215
Cost of labor: 69.56521739130434
Total Cost: 73.91304347826086
'''


@should_print
def test_paint_job_estimator_2(output):
    functions.paint_job_estimator(750, 15.95)

    assert output == '''
Gallons of paint required: 6.521739130434782
Hours of labor required: 52.17391304347826
Cost of paint: 104.02173913043477
Cost of labor: 1043.4782608695652
Total Cost: 1147.5
'''


@should_print
def test_monthly_sales_tax(output):
    functions.monthly_sales_tax(123456.79)

    assert output == '''
Monthly sales: 123456.79
State sales tax: 4938.2716
County sales tax: 2469.1358
Total sales tax: 7407.4074
'''


@should_print
def test_monthly_sales_tax_2(output):
    functions.monthly_sales_tax(4321567.21)

    assert output == '''
Monthly sales: 4321567.21
State sales tax: 172862.6884
County sales tax: 86431.3442
Total sales tax: 259294.03260000004
'''

[((35, 4, 35, 26), 'functions.sales_tax', 'functions.sales_tax', ({(35, 24, 35, 25): '(1)'}, {}), '(1)', False, 'import functions\n'), ((48, 4, 48, 30), 'functions.sales_tax', 'functions.sales_tax', ({(48, 24, 48, 29): '(99.99)'}, {}), '(99.99)', False, 'import functions\n'), ((61, 4, 61, 29), 'functions.sales_tax', 'functions.sales_tax', ({(61, 24, 61, 28): '(5.95)'}, {}), '(5.95)', False, 'import functions\n'), ((81, 4, 81, 33), 'functions.property_tax', 'functions.property_tax', ({(81, 27, 81, 32): '(10000)'}, {}), '(10000)', False, 'import functions\n'), ((91, 4, 91, 36), 'functions.property_tax', 'functions.property_tax', ({(91, 27, 91, 35): '(99999.95)'}, {}), '(99999.95)', False, 'import functions\n'), ((118, 4, 118, 41), 'functions.paint_job_estimator', 'functions.paint_job_estimator', ({(118, 34, 118, 36): '(50)', (118, 38, 118, 40): '(10)'}, {}), '(50, 10)', False, 'import functions\n'), ((131, 4, 131, 45), 'functions.paint_job_estimator', 'functions.paint_job_estimator', ({(131, 34, 131, 37): '(750)', (131, 39, 131, 44): '(15.95)'}, {}), '(750, 15.95)', False, 'import functions\n'), ((144, 4, 144, 42), 'functions.monthly_sales_tax', 'functions.monthly_sales_tax', ({(144, 32, 144, 41): '(123456.79)'}, {}), '(123456.79)', False, 'import functions\n'), ((156, 4, 156, 43), 'functions.monthly_sales_tax', 'functions.monthly_sales_tax', ({(156, 32, 156, 42): '(4321567.21)'}, {}), '(4321567.21)', False, 'import functions\n'), ((7, 11, 7, 39), 'functions.add_em_up', 'functions.add_em_up', ({(7, 31, 7, 32): '(1)', (7, 34, 7, 35): '(2)', (7, 37, 7, 38): '(3)'}, {}), '(1, 2, 3)', False, 'import functions\n'), ((8, 11, 8, 39), 'functions.add_em_up', 'functions.add_em_up', ({(8, 31, 8, 32): '(4)', (8, 34, 8, 35): '(5)', (8, 37, 8, 38): '(6)'}, {}), '(4, 5, 6)', False, 'import functions\n'), ((12, 11, 12, 44), 'functions.sub_sub_hubbub', 'functions.sub_sub_hubbub', ({(12, 36, 12, 37): '(1)', (12, 39, 12, 40): '(2)', (12, 42, 12, 43): '(3)'}, {}), '(1, 2, 3)', False, 'import functions\n'), ((16, 11, 16, 38), 'functions.square_area', 'functions.square_area', ({(16, 33, 16, 34): '(5)', (16, 36, 16, 37): '(5)'}, {}), '(5, 5)', False, 'import functions\n'), ((17, 11, 17, 38), 'functions.square_area', 'functions.square_area', ({(17, 33, 17, 34): '(3)', (17, 36, 17, 37): '(5)'}, {}), '(3, 5)', False, 'import functions\n'), ((18, 11, 18, 38), 'functions.square_area', 'functions.square_area', ({(18, 33, 18, 34): '(2)', (18, 36, 18, 37): '(2)'}, {}), '(2, 2)', False, 'import functions\n'), ((22, 11, 22, 35), 'functions.circle_area', 'functions.circle_area', ({(22, 33, 22, 34): '(1)'}, {}), '(1)', False, 'import functions\n'), ((22, 39, 22, 51), 'pytest.approx', 'approx', ({(22, 46, 22, 50): '(3.14)'}, {}), '(3.14)', False, 'from pytest import approx\n'), ((23, 11, 23, 35), 'functions.circle_area', 'functions.circle_area', ({(23, 33, 23, 34): '(5)'}, {}), '(5)', False, 'import functions\n'), ((23, 39, 23, 51), 'pytest.approx', 'approx', ({(23, 46, 23, 50): '(78.5)'}, {}), '(78.5)', False, 'from pytest import approx\n'), ((27, 11, 27, 43), 'functions.kilometers_to_miles', 'functions.kilometers_to_miles', ({(27, 41, 27, 42): '(1)'}, {}), '(1)', False, 'import functions\n'), ((27, 47, 27, 61), 'pytest.approx', 'approx', ({(27, 54, 27, 60): '(0.6214)'}, {}), '(0.6214)', False, 'from pytest import approx\n'), ((28, 11, 28, 44), 'functions.kilometers_to_miles', 'functions.kilometers_to_miles', ({(28, 41, 28, 43): '(0.5)'}, {}), '(0.5)', False, 'import functions\n'), ((28, 48, 28, 62), 'pytest.approx', 'approx', ({(28, 55, 28, 61): '(0.3107)'}, {}), '(0.3107)', False, 'from pytest import approx\n'), ((29, 11, 29, 43), 'functions.kilometers_to_miles', 'functions.kilometers_to_miles', ({(29, 41, 29, 42): '(0)'}, {}), '(0)', False, 'import functions\n'), ((29, 47, 29, 58), 'pytest.approx', 'approx', ({(29, 54, 29, 57): '(0.0)'}, {}), '(0.0)', False, 'from pytest import approx\n'), ((30, 11, 30, 44), 'functions.kilometers_to_miles', 'functions.kilometers_to_miles', ({(30, 41, 30, 43): '(40)'}, {}), '(40)', False, 'import functions\n'), ((30, 48, 30, 74), 'pytest.approx', 'approx', ({(30, 55, 30, 73): '(24.855999999999998)'}, {}), '(24.855999999999998)', False, 'from pytest import approx\n'), ((73, 11, 73, 42), 'functions.min_insurance', 'functions.min_insurance', ({(73, 35, 73, 41): '(100000)'}, {}), '(100000)', False, 'import functions\n'), ((73, 46, 73, 61), 'pytest.approx', 'approx', ({(73, 53, 73, 60): '(80000.0)'}, {}), '(80000.0)', False, 'from pytest import approx\n'), ((74, 11, 74, 45), 'functions.min_insurance', 'functions.min_insurance', ({(74, 35, 74, 44): '(123456789)'}, {}), '(123456789)', False, 'import functions\n'), ((74, 49, 74, 67), 'pytest.approx', 'approx', ({(74, 56, 74, 66): '(98765431.2)'}, {}), '(98765431.2)', False, 'from pytest import approx\n'), ((75, 11, 75, 37), 'functions.min_insurance', 'functions.min_insurance', ({(75, 35, 75, 36): '(0)'}, {}), '(0)', False, 'import functions\n'), ((75, 41, 75, 52), 'pytest.approx', 'approx', ({(75, 48, 75, 51): '(0.0)'}, {}), '(0.0)', False, 'from pytest import approx\n'), ((76, 11, 76, 45), 'functions.min_insurance', 'functions.min_insurance', ({(76, 35, 76, 44): '(-54317890)'}, {}), '(-54317890)', False, 'import functions\n'), ((76, 49, 76, 68), 'pytest.approx', 'approx', ({(76, 56, 76, 67): '(-43454312.0)'}, {}), '(-43454312.0)', False, 'from pytest import approx\n'), ((100, 11, 100, 33), 'functions.bmi', 'functions.bmi', ({(100, 25, 100, 28): '(160)', (100, 30, 100, 32): '(67)'}, {}), '(160, 67)', False, 'import functions\n'), ((100, 37, 100, 56), 'pytest.approx', 'approx', ({(100, 44, 100, 55): '(25.05680552)'}, {}), '(25.05680552)', False, 'from pytest import approx\n'), ((101, 11, 101, 33), 'functions.bmi', 'functions.bmi', ({(101, 25, 101, 28): '(200)', (101, 30, 101, 32): '(72)'}, {}), '(200, 72)', False, 'import functions\n'), ((101, 37, 101, 56), 'pytest.approx', 'approx', ({(101, 44, 101, 55): '(27.12191358)'}, {}), '(27.12191358)', False, 'from pytest import approx\n'), ((102, 11, 102, 33), 'functions.bmi', 'functions.bmi', ({(102, 25, 102, 28): '(120)', (102, 30, 102, 32): '(60)'}, {}), '(120, 60)', False, 'import functions\n'), ((102, 37, 102, 56), 'pytest.approx', 'approx', ({(102, 44, 102, 55): '(23.43333333)'}, {}), '(23.43333333)', False, 'from pytest import approx\n'), ((106, 11, 106, 36), 'functions.calories', 'functions.calories', ({(106, 30, 106, 31): '(5)', (106, 33, 106, 35): '(20)'}, {}), '(5, 20)', False, 'import functions\n'), ((107, 11, 107, 35), 'functions.calories', 'functions.calories', ({(107, 30, 107, 31): '(1)', (107, 33, 107, 34): '(1)'}, {}), '(1, 1)', False, 'import functions\n'), ((111, 11, 111, 44), 'functions.earnings', 'functions.earnings', ({(111, 30, 111, 33): '(100)', (111, 35, 111, 38): '(100)', (111, 40, 111, 43): '(100)'}, {}), '(100, 100, 100)', False, 'import functions\n'), ((112, 11, 112, 42), 'functions.earnings', 'functions.earnings', ({(112, 30, 112, 32): '(50)', (112, 34, 112, 36): '(75)', (112, 38, 112, 41): '(100)'}, {}), '(50, 75, 100)', False, 'import functions\n'), ((113, 11, 113, 42), 'functions.earnings', 'functions.earnings', ({(113, 30, 113, 31): '(0)', (113, 33, 113, 37): '(1000)', (113, 39, 113, 41): '(79)'}, {}), '(0, 1000, 79)', False, 'import functions\n')]