Beispiel #1
0
def test_invalid_day():
    """Ensure we raise an exception when given a bogus day"""
    # Create a fake namespace and set its "day" to something dumb
    n = FakeNamespace()
    n.day = "Foosday"

    with pytest.raises(UserInputError):
        food(n)
Beispiel #2
0
def test_valid_day():
    """Ensure we get proper output and no errors when given a correct day"""
    # Create fake namespace
    n = FakeNamespace()

    try:
        n.day = "Monday"
        assert food(n) == "Gug wants one gallon of saurkraut"
        n.day = "monday"
        assert food(n) == "Gug wants one gallon of saurkraut"
    except UserInputError:
        raise pytest.fail("DID RAISE {0}".format(UserInputError))
Beispiel #3
0
def test_weekday_inputs():
    """Ensure we recieve proper output for each proper weekday"""
    weekdays = {
        "Sunday": "frozen corn",
        "Monday": "one gallon of saurkraut",
        "Tuesday": "hot dog water",
        "Wednesday": "drywall",
        "Thursday": "grass clippings",
        "Friday": "old bananas",
        "Saturday": "dirt",
    }

    for day, food_type in weekdays.items():
        n = FakeNamespace()
        n.day = day
        assert food(n) == "Gug wants {}".format(food_type)
Beispiel #4
0
def test_weekday_inputs_with_capitalization():
    """
    Ensure we recieve proper output for each weekday with any captilization
    """
    weekdays = {
        "SuNday": "frozen corn",
        "MONDAY": "one gallon of saurkraut",
        "TUESday": "hot dog water",
        "WednesdAY": "drywall",
        "ThursDAY": "grass clippings",
        "FRIDay": "old bananas",
        "SaTuRdAy": "dirt",
    }

    for day, food_type in weekdays.items():
        n = FakeNamespace()
        n.day = day
        assert food(n) == "Gug wants {}".format(food_type)