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
'''

[((906, 928), 'functions.sales_tax', 'functions.sales_tax', (['(1)'], {}), '(1)\n', (925, 928), False, 'import functions\n'), ((1116, 1142), 'functions.sales_tax', 'functions.sales_tax', (['(99.99)'], {}), '(99.99)\n', (1135, 1142), False, 'import functions\n'), ((1353, 1378), 'functions.sales_tax', 'functions.sales_tax', (['(5.95)'], {}), '(5.95)\n', (1372, 1378), False, 'import functions\n'), ((1898, 1927), 'functions.property_tax', 'functions.property_tax', (['(10000)'], {}), '(10000)\n', (1920, 1927), False, 'import functions\n'), ((2062, 2094), 'functions.property_tax', 'functions.property_tax', (['(99999.95)'], {}), '(99999.95)\n', (2084, 2094), False, 'import functions\n'), ((2722, 2759), 'functions.paint_job_estimator', 'functions.paint_job_estimator', (['(50)', '(10)'], {}), '(50, 10)\n', (2751, 2759), False, 'import functions\n'), ((3038, 3079), 'functions.paint_job_estimator', 'functions.paint_job_estimator', (['(750)', '(15.95)'], {}), '(750, 15.95)\n', (3067, 3079), False, 'import functions\n'), ((3341, 3379), 'functions.monthly_sales_tax', 'functions.monthly_sales_tax', (['(123456.79)'], {}), '(123456.79)\n', (3368, 3379), False, 'import functions\n'), ((3575, 3614), 'functions.monthly_sales_tax', 'functions.monthly_sales_tax', (['(4321567.21)'], {}), '(4321567.21)\n', (3602, 3614), False, 'import functions\n'), ((113, 141), 'functions.add_em_up', 'functions.add_em_up', (['(1)', '(2)', '(3)'], {}), '(1, 2, 3)\n', (132, 141), False, 'import functions\n'), ((158, 186), 'functions.add_em_up', 'functions.add_em_up', (['(4)', '(5)', '(6)'], {}), '(4, 5, 6)\n', (177, 186), False, 'import functions\n'), ((233, 266), 'functions.sub_sub_hubbub', 'functions.sub_sub_hubbub', (['(1)', '(2)', '(3)'], {}), '(1, 2, 3)\n', (257, 266), False, 'import functions\n'), ((310, 337), 'functions.square_area', 'functions.square_area', (['(5)', '(5)'], {}), '(5, 5)\n', (331, 337), False, 'import functions\n'), ((355, 382), 'functions.square_area', 'functions.square_area', (['(3)', '(5)'], {}), '(3, 5)\n', (376, 382), False, 'import functions\n'), ((400, 427), 'functions.square_area', 'functions.square_area', (['(2)', '(2)'], {}), '(2, 2)\n', (421, 427), False, 'import functions\n'), ((470, 494), 'functions.circle_area', 'functions.circle_area', (['(1)'], {}), '(1)\n', (491, 494), False, 'import functions\n'), ((498, 510), 'pytest.approx', 'approx', (['(3.14)'], {}), '(3.14)\n', (504, 510), False, 'from pytest import approx\n'), ((522, 546), 'functions.circle_area', 'functions.circle_area', (['(5)'], {}), '(5)\n', (543, 546), False, 'import functions\n'), ((550, 562), 'pytest.approx', 'approx', (['(78.5)'], {}), '(78.5)\n', (556, 562), False, 'from pytest import approx\n'), ((608, 640), 'functions.kilometers_to_miles', 'functions.kilometers_to_miles', (['(1)'], {}), '(1)\n', (637, 640), False, 'import functions\n'), ((644, 658), 'pytest.approx', 'approx', (['(0.6214)'], {}), '(0.6214)\n', (650, 658), False, 'from pytest import approx\n'), ((670, 704), 'functions.kilometers_to_miles', 'functions.kilometers_to_miles', (['(0.5)'], {}), '(0.5)\n', (699, 704), False, 'import functions\n'), ((707, 721), 'pytest.approx', 'approx', (['(0.3107)'], {}), '(0.3107)\n', (713, 721), False, 'from pytest import approx\n'), ((733, 765), 'functions.kilometers_to_miles', 'functions.kilometers_to_miles', (['(0)'], {}), '(0)\n', (762, 765), False, 'import functions\n'), ((769, 780), 'pytest.approx', 'approx', (['(0.0)'], {}), '(0.0)\n', (775, 780), False, 'from pytest import approx\n'), ((792, 825), 'functions.kilometers_to_miles', 'functions.kilometers_to_miles', (['(40)'], {}), '(40)\n', (821, 825), False, 'import functions\n'), ((829, 855), 'pytest.approx', 'approx', (['(24.855999999999998)'], {}), '(24.855999999999998)\n', (835, 855), False, 'from pytest import approx\n'), ((1600, 1631), 'functions.min_insurance', 'functions.min_insurance', (['(100000)'], {}), '(100000)\n', (1623, 1631), False, 'import functions\n'), ((1635, 1650), 'pytest.approx', 'approx', (['(80000.0)'], {}), '(80000.0)\n', (1641, 1650), False, 'from pytest import approx\n'), ((1662, 1696), 'functions.min_insurance', 'functions.min_insurance', (['(123456789)'], {}), '(123456789)\n', (1685, 1696), False, 'import functions\n'), ((1700, 1718), 'pytest.approx', 'approx', (['(98765431.2)'], {}), '(98765431.2)\n', (1706, 1718), False, 'from pytest import approx\n'), ((1730, 1756), 'functions.min_insurance', 'functions.min_insurance', (['(0)'], {}), '(0)\n', (1753, 1756), False, 'import functions\n'), ((1760, 1771), 'pytest.approx', 'approx', (['(0.0)'], {}), '(0.0)\n', (1766, 1771), False, 'from pytest import approx\n'), ((1783, 1817), 'functions.min_insurance', 'functions.min_insurance', (['(-54317890)'], {}), '(-54317890)\n', (1806, 1817), False, 'import functions\n'), ((1821, 1840), 'pytest.approx', 'approx', (['(-43454312.0)'], {}), '(-43454312.0)\n', (1827, 1840), False, 'from pytest import approx\n'), ((2216, 2238), 'functions.bmi', 'functions.bmi', (['(160)', '(67)'], {}), '(160, 67)\n', (2229, 2238), False, 'import functions\n'), ((2242, 2261), 'pytest.approx', 'approx', (['(25.05680552)'], {}), '(25.05680552)\n', (2248, 2261), False, 'from pytest import approx\n'), ((2273, 2295), 'functions.bmi', 'functions.bmi', (['(200)', '(72)'], {}), '(200, 72)\n', (2286, 2295), False, 'import functions\n'), ((2299, 2318), 'pytest.approx', 'approx', (['(27.12191358)'], {}), '(27.12191358)\n', (2305, 2318), False, 'from pytest import approx\n'), ((2330, 2352), 'functions.bmi', 'functions.bmi', (['(120)', '(60)'], {}), '(120, 60)\n', (2343, 2352), False, 'import functions\n'), ((2356, 2375), 'pytest.approx', 'approx', (['(23.43333333)'], {}), '(23.43333333)\n', (2362, 2375), False, 'from pytest import approx\n'), ((2410, 2435), 'functions.calories', 'functions.calories', (['(5)', '(20)'], {}), '(5, 20)\n', (2428, 2435), False, 'import functions\n'), ((2454, 2478), 'functions.calories', 'functions.calories', (['(1)', '(1)'], {}), '(1, 1)\n', (2472, 2478), False, 'import functions\n'), ((2519, 2552), 'functions.earnings', 'functions.earnings', (['(100)', '(100)', '(100)'], {}), '(100, 100, 100)\n', (2537, 2552), False, 'import functions\n'), ((2572, 2603), 'functions.earnings', 'functions.earnings', (['(50)', '(75)', '(100)'], {}), '(50, 75, 100)\n', (2590, 2603), False, 'import functions\n'), ((2623, 2654), 'functions.earnings', 'functions.earnings', (['(0)', '(1000)', '(79)'], {}), '(0, 1000, 79)\n', (2641, 2654), False, 'import functions\n')]