Exemple #1
0
def test_add_to_log(tmpdir):
    logs = [
        FoodLog(
            utc.localize(datetime.datetime.utcnow()),
            1,
            5,
            ['sleepy', 'hungry'],
            ['broccoli'],
            ['test'],
            SNACK,
            ""
        ),
        FoodLog(
            utc.localize(datetime.datetime.utcnow()),
            5,
            2,
            ['happy'],
            ['popcorn', 'butter'],
            ['movies', 'test'],
            SNACK,
            "I am a note"
        )
    ]
    log_file = str(tmpdir.join("log.txt"))
    for l in logs:
        add_log_to_file(log_file, l)
    with open(log_file, 'r') as infile:
        results = [json_to_food_log(l) for l in infile]
    assert logs == results
Exemple #2
0
def test_add_to_log(tmpdir):
    logs = [
        FoodLog(utc.localize(datetime.datetime.utcnow()), 1, 5,
                ['sleepy', 'hungry'], ['broccoli'], ['test'], SNACK, ""),
        FoodLog(utc.localize(datetime.datetime.utcnow()), 5, 2, ['happy'],
                ['popcorn', 'butter'], ['movies', 'test'], SNACK,
                "I am a note")
    ]
    log_file = str(tmpdir.join("log.txt"))
    for l in logs:
        add_log_to_file(log_file, l)
    with open(log_file, 'r') as infile:
        results = [json_to_food_log(l) for l in infile]
    assert logs == results
Exemple #3
0
def test_to_from_json(
        date,
        mood_rating,
        food_rating,
        mood_tags,
        food_tags,
        entry_tags,
        meal,
        note
):
    assume(date > utc.localize(datetime.datetime(2000, 1, 1, 1)))
    original = FoodLog(
        date,
        mood_rating,
        food_rating,
        mood_tags,
        food_tags,
        entry_tags,
        meal,
        note
    )
    assert original == json_to_food_log(food_log_to_json(original))
Exemple #4
0
def test_to_from_json(date, mood_rating, food_rating, mood_tags, food_tags,
                      entry_tags, meal, note):
    assume(date > utc.localize(datetime.datetime(2000, 1, 1, 1)))
    original = FoodLog(date, mood_rating, food_rating, mood_tags, food_tags,
                       entry_tags, meal, note)
    assert original == json_to_food_log(food_log_to_json(original))