Exemplo n.º 1
0
def test_replace_expense():
    l = test_Init()
    assert (len(l) == 7)

    apartment = create_apartment(8, "gas", 200)
    replace_expense(l, apartment)
    assert (l[0]["ammount"] == 200)
Exemplo n.º 2
0
def test_Init():
    building = []
    building.append(create_apartment(8, "gas", 215))
    building.append(create_apartment(8, "gas", 120))
    building.append(create_apartment(12, "electricity", 110))
    building.append(create_apartment(3, "gas", 170))
    building.append(create_apartment(15, "other", 50))
    building.append(create_apartment(16, "water", 165))
    building.append(create_apartment(8, "electricity", 200))
    return building
def UI_replace_expense(building, undo_steps, apartment_id, expense_type,
                       ammount):
    '''
        Validates if the set of data is correct and replaces the specified expense cost
    '''
    try:
        apartment = create_apartment(int(apartment_id), expense_type,
                                     int(ammount))
        validate_apartment(apartment)
        record_undo(building, undo_steps)
        replace_expense(building, apartment)
    except ValueError as ve:
        print("Invalid input", ve)
        raise ve
def UI_add_apartment(building, undo_steps, apartment_id, expense_type,
                     ammount):
    '''
        Validates if the set of data is correct and creates a new entry in the list
    '''
    try:

        apartment = create_apartment(int(apartment_id), expense_type,
                                     int(ammount))
        validate_apartment(apartment)
        record_undo(building, undo_steps)
        add_apartment(building, apartment)
    except ValueError as ve:
        print("Invalid input", ve)
        raise ve
def test_create_apartment():
    apartment = {"apartment_id": 1, "expense_type": "gas", "ammount": 200}
    assert (create_apartment(1, "gas", 200) == apartment)
def test_set_ammount():
    apartment = create_apartment(1, "gas", 200)
    set_ammount(apartment, 100)
    assert (get_ammount(apartment) == 100)
def test_set_expense_type():
    apartment = create_apartment(1, "gas", 200)
    set_expense_type(apartment, "water")
    assert (get_expense_type(apartment) == "water")
def test_set_apartment_id():
    apartment = create_apartment(1, "gas", 200)
    set_apartment_id(apartment, 3)
    assert (get_apartment_id(apartment) == 3)
def test_get_expense_type():
    apartment = create_apartment(1, "gas", 200)
    assert (get_expense_type(apartment) == "gas")
def test_get_apartment_id():
    apartment = create_apartment(1, "gas", 200)
    assert (get_apartment_id(apartment) == 1)
Exemplo n.º 11
0
def test_add_apartment():
    l = test_Init()
    assert (len(l) == 7)

    add_apartment(l, create_apartment(9, "water", 200))
    assert (len(l) == 8)