Beispiel #1
0
def test_FHDay_dinner():
    day = FHDay("10.10.2010", 200)

    assert day.date == "10.10.2010"
    assert day.weight == 200
    assert day.total == 0

    product = FHProduct("DProduct", 120)

    day.AddDinner(product)

    assert day.dinner_sum == 120
    assert len(day.dinner) == 1
    assert str(day.dinner[0]) == 'DProduct (120)'
    assert day.total == 120

    product = FHProduct("D2Product", 130)

    day.AddDinner(product)

    assert day.dinner_sum == 250
    assert len(day.dinner) == 2
    assert str(day.dinner[0]) == 'DProduct (120)'
    assert str(day.dinner[1]) == 'D2Product (130)'
    assert day.total == 250
Beispiel #2
0
def test_FHDay_lunch():
    day = FHDay("10.10.2010", 200)

    assert day.date == "10.10.2010"
    assert day.weight == 200
    assert day.total == 0

    product = FHProduct("LProduct", 40)

    day.AddLunch(product)

    assert day.lunch_sum == 40
    assert len(day.lunch) == 1
    assert str(day.lunch[0]) == 'LProduct (40)'
    assert day.total == 40

    product = FHProduct("L2Product", 50)

    day.AddLunch(product)

    assert day.lunch_sum == 90
    assert len(day.lunch) == 2
    assert str(day.lunch[0]) == 'LProduct (40)'
    assert str(day.lunch[1]) == 'L2Product (50)'
    assert day.total == 90
Beispiel #3
0
def test_FHDay_breakfast():
    day = FHDay("10.10.2010", 200)

    assert day.date == "10.10.2010"
    assert day.weight == 200
    assert day.total == 0

    product = FHProduct("BProduct", 20)

    day.AddBreakfast(product)

    assert day.breakfast_sum == 20
    assert len(day.breakfast) == 1
    assert str(day.breakfast[0]) == 'BProduct (20)'
    assert day.total == 20

    product = FHProduct("B2Product", 30)

    day.AddBreakfast(product)

    assert day.breakfast_sum == 50
    assert len(day.breakfast) == 2
    assert str(day.breakfast[0]) == 'BProduct (20)'
    assert str(day.breakfast[1]) == 'B2Product (30)'
    assert day.total == 50
Beispiel #4
0
def test_FHDay_snack():
    day = FHDay("10.10.2010", 200)

    assert day.date == "10.10.2010"
    assert day.weight == 200
    assert day.total == 0

    product = FHProduct("SProduct", 220)

    day.AddSnack(product)

    assert day.snacks_sum == 220
    assert len(day.snacks) == 1
    assert str(day.snacks[0]) == 'SProduct (220)'
    assert day.total == 220

    product = FHProduct("S2Product", 230)

    day.AddSnack(product)

    assert day.snacks_sum == 450
    assert len(day.snacks) == 2
    assert str(day.snacks[0]) == 'SProduct (220)'
    assert str(day.snacks[1]) == 'S2Product (230)'
    assert day.total == 450
Beispiel #5
0
def DayExample():
    day = FHDay("03.03.20", 80)

    breakfast = FHProduct("egg", 50)
    day.AddBreakfast(breakfast)

    first_snack = FHProduct("ChocoBar", 200, "Milka")
    day.AddSnack(first_snack)

    lunch = FHProduct("salad", 100)
    day.AddLunch(lunch)
    lunch = FHProduct("Beef", 500)
    day.AddLunch(lunch)

    second_snack = FHProduct("jogurt", 125, "Danone")
    day.AddSnack(second_snack)

    dinner = FHProduct("steak", 550, "Miratorg")
    day.AddDinner(dinner)

    print(day)
    print()

    return day
Beispiel #6
0
def test_FHPersonalDataBase():
    base = FHPersonalDataBase("TestName", 2000, 80)

    assert base.name == "TestName"
    assert base.desired_kcal == 2000
    assert base.desired_weight == 80

    day = FHDay("10.10.2010", 200)

    product = FHProduct("BProduct", 20)
    day.AddBreakfast(product)

    product = FHProduct("LProduct", 40)
    day.AddLunch(product)

    product = FHProduct("DProduct", 120)
    day.AddDinner(product)

    product = FHProduct("SProduct", 220)
    day.AddSnack(product)

    base[day.date] = day

    assert base[day.date].total == 400
Beispiel #7
0
def test_FHDay_full():
    day = FHDay("10.10.2010", 200)

    assert day.date == "10.10.2010"
    assert day.weight == 200
    assert day.total == 0

    product = FHProduct("BProduct", 20)

    day.AddBreakfast(product)

    assert day.breakfast_sum == 20
    assert len(day.breakfast) == 1
    assert str(day.breakfast[0]) == 'BProduct (20)'
    assert day.total == 20

    product = FHProduct("LProduct", 40)

    day.AddLunch(product)

    assert day.breakfast_sum == 20
    assert day.lunch_sum == 40
    assert len(day.lunch) == 1
    assert len(day.breakfast) == 1
    assert str(day.lunch[0]) == 'LProduct (40)'
    assert str(day.breakfast[0]) == 'BProduct (20)'
    assert day.total == 60

    product = FHProduct("DProduct", 120)

    day.AddDinner(product)

    assert day.dinner_sum == 120
    assert day.breakfast_sum == 20
    assert day.lunch_sum == 40
    assert len(day.dinner) == 1
    assert len(day.lunch) == 1
    assert len(day.breakfast) == 1
    assert str(day.dinner[0]) == 'DProduct (120)'
    assert str(day.lunch[0]) == 'LProduct (40)'
    assert str(day.breakfast[0]) == 'BProduct (20)'
    assert day.total == 180

    product = FHProduct("SProduct", 220)

    day.AddSnack(product)
    assert day.dinner_sum == 120
    assert day.breakfast_sum == 20
    assert day.lunch_sum == 40
    assert day.snacks_sum == 220
    assert len(day.dinner) == 1
    assert len(day.lunch) == 1
    assert len(day.breakfast) == 1
    assert len(day.snacks) == 1
    assert str(day.dinner[0]) == 'DProduct (120)'
    assert str(day.lunch[0]) == 'LProduct (40)'
    assert str(day.breakfast[0]) == 'BProduct (20)'
    assert str(day.snacks[0]) == 'SProduct (220)'
    assert day.total == 400

    storage = day.GetAll()
    keys = list(storage.keys())
    assert len(keys) == 4

    key_breakfast = list(storage['Breakfast'].keys())
    assert len(key_breakfast) == 1
    assert str(key_breakfast[0]) == 'BProduct (20)'
    assert storage['Breakfast'][key_breakfast[0]] == 20