Ejemplo n.º 1
0
def tab_console():
    total = raw_input(" Total: ")
    guests = raw_input(" Guests: ")

    try:
        totalCheck, splitAmount = tab.calculate(total, guests)
        print("\n Total: " + str(totalCheck) + "\n Split Between " + guests +
              " Guests:" + str(splitAmount) + "\n")
    except Exception as e:
        print("\n Try again: " + type(e).__name__ + "\n")
Ejemplo n.º 2
0
def test_tab_split_once():
    assert tab.calculate(8, 1)[1] == ['9.20']
Ejemplo n.º 3
0
def test_tab_split_unevenByTwo():
    assert tab.calculate(15.17, 3)[1] == ['5.82', '5.82', '5.81']
Ejemplo n.º 4
0
def test_tab_split_unevenByOne():
    assert tab.calculate(2.01, 2)[1] == ['1.16', '1.15']
Ejemplo n.º 5
0
def test_tab_split_even():
    assert tab.calculate(20, 2)[1] == ['11.50', '11.50']
Ejemplo n.º 6
0
def test_tab_total_addgratuity():
    # 15% gratuity
    assert tab.calculate(20, 1)[0] == '23.00'
Ejemplo n.º 7
0
def test_tab_split_returns_list():
    assert isinstance(tab.calculate(20, 3)[1], list)
Ejemplo n.º 8
0
def test_tab_split_four():
    assert tab.calculate(8, 4)[1] == ['2.30', '2.30', '2.30', '2.30']
Ejemplo n.º 9
0
def test_tab_total_negative():
    with pytest.raises(tab.InvalidTotalError):
        tab.calculate(-1, 3)
Ejemplo n.º 10
0
def test_tab_guests_zero():
    with pytest.raises(tab.InvalidGuestsError):
        tab.calculate(20.3, 0)
Ejemplo n.º 11
0
def test_tab_total_zero():
    with pytest.raises(tab.InvalidTotalError):
        tab.calculate(0, 3)
Ejemplo n.º 12
0
def test_tab_guests_invalid_input():
    with pytest.raises(tab.InvalidInputError):
        tab.calculate(20.3, "test")
Ejemplo n.º 13
0
def test_tab_total_invalid_input():
    with pytest.raises(tab.InvalidInputError):
        tab.calculate("test", 3)
Ejemplo n.º 14
0
def test_tab_split_roundedToTwoDecimalPlaces():
    assert (str(tab.calculate(115, 1)[1][0])[-3])[0] == "."
Ejemplo n.º 15
0
def test_tab_split_list_returns_string():
    assert isinstance(tab.calculate(20, 3)[1][0], str)
Ejemplo n.º 16
0
def test_tab_split_twice():
    assert tab.calculate(8, 2)[1] == ['4.60', '4.60']
Ejemplo n.º 17
0
def test_tab_split_thrice():
    assert tab.calculate(8, 3)[1] == ['3.07', '3.07', '3.06']
Ejemplo n.º 18
0
def test_tab_returns_float():
    assert isinstance(tab.calculate(20, 3), tuple)
Ejemplo n.º 19
0
def test_tab_total_returns_string():
    assert isinstance(tab.calculate(20, 3)[0], str)
Ejemplo n.º 20
0
def test_tab_guests_negative():
    with pytest.raises(tab.InvalidGuestsError):
        tab.calculate(20.3, -1)