Skip to content

Faitholo/meal_planner

Repository files navigation

Meal Planner CLI Application

A command-line tool that provides meal suggestions based on category and diet preferences.

Overview

The Meal Planner is a CLI application that helps users discover meal options by specifying meal categories (Breakfast, Lunch, Dinner, Snacks) and diet types (General, Vegetarian, Vegan, Keto, Gluten-free, Low-carb, Healthy, Indulgent).

Features

  • Multiple Categories & Diets: Support for comma-separated lists
  • Order Preservation: Results returned in user-specified order
  • Comprehensive Error Handling: Clear error messages for invalid inputs
  • Case-Insensitive Input: Flexible input handling
  • Complete Meal Lists: Shows all available meals for each category-diet combination

Usage

Basic Usage

python3 solution.py --category [category] --diet [diet]

Examples

Single category and diet:

python3 solution.py --category breakfast --diet vegan

Multiple categories:

python3 solution.py --category "lunch,dinner,breakfast" --diet general

Multiple diets:

python3 solution.py --category lunch --diet "vegan,vegetarian"

Multiple categories and diets:

python3 solution.py --category "breakfast,lunch" --diet "vegan,general"

Output Format

Success Messages

The application displays all available meals for each category-diet combination in a numbered list format:

SUCCESS: here is your meal suggestion:
Category: Breakfast - Diet: Vegan
1. Tofu scramble with veggies
2. Peanut butter oatmeal
3. Vegan banana muffins
4. Almond milk smoothie
5. Chia seed pudding with coconut milk

For multiple categories and diets, each combination is displayed separately:

python3 solution.py --category "lunch,dinner" --diet "vegan,general"
SUCCESS: here is your meal suggestion:
Category: Lunch - Diet: Vegan
1. Falafel wrap
2. Grilled veggie sandwich
3. Chickpea salad
4. Lentil soup with flatbread
5. Vegan burrito bowl

SUCCESS: here is your meal suggestion:
Category: Lunch - Diet: General
1. Tuna sandwich
2. Chicken wrap
3. Spaghetti bolognese
4. Rice and beans
5. Grilled cheese with tomato soup
6. BBQ chicken with coleslaw

SUCCESS: here is your meal suggestion:
Category: Dinner - Diet: Vegan
1. Lentil stew
2. Chickpea stir-fry
3. Vegan shepherd's pie
4. Stuffed zucchini boats
5. Sweet potato and black bean tacos

SUCCESS: here is your meal suggestion:
Category: Dinner - Diet: General
1. Grilled chicken with veggies
2. Salmon with quinoa
3. Tomato soup with bread
4. Vegetable stir-fry
5. Beef stew with potatoes
6. Shrimp pasta

Error Messages

  • Missing arguments: ERROR: Invalid input. Please try again!
  • Invalid category: ERROR: Meal category not found. Available categories: Breakfast, Lunch, Dinner, Snacks.
  • Invalid diet: ERROR: Diet not found. Available options: General, Vegetarian, Vegan, Keto, Gluten-free, Low-carb, Healthy, Indulgent.
  • No meals found: ERROR: No meals found for {category} with diet {diet}.
  • Empty input: ERROR: Empty input received. Please enter a valid choice.

Available Options

Categories

  • Breakfast: Morning meal options
  • Lunch: Midday meal options
  • Dinner: Evening meal options
  • Snacks: Light meal and snack options

Diet Types

  • General: Standard meal options
  • Vegetarian: No meat, but may include dairy and eggs
  • Vegan: Plant-based options only
  • Keto: Low-carb, high-fat diet options
  • Gluten-free: Options without gluten-containing ingredients
  • Low-carb: Reduced carbohydrate options
  • Healthy: Nutritious, balanced meal options
  • Indulgent: Rich, comfort food options

Testing

The application includes two comprehensive test suites:

Pytest (Recommended)

Run the enhanced pytest suite with 74 comprehensive tests:

python3 -m pytest test_meal_planner_pytest.py -v

Run with custom pytest runner for enhanced reporting:

python3 run_pytest.py

Pytest Features

  • 74 comprehensive tests with 146+ parametrized test combinations
  • Output order verification using stdout.find() position-based assertions
  • Strict error handling validation with exit code checking
  • Performance testing and timing capabilities
  • Class-based organization for logical test grouping
  • Flexible test execution with keyword and class filtering

Pytest Examples

# Run all tests with verbose output
python3 -m pytest test_meal_planner_pytest.py -v

# Run specific test class
python3 -m pytest test_meal_planner_pytest.py::TestCLIInterface -v

# Run tests by keyword (e.g., all tests with "multiple" in name)
python3 -m pytest -k "multiple" -v

# Run error handling tests only
python3 -m pytest test_meal_planner_pytest.py::TestCLIErrorHandling -v

# Performance analysis
python3 -m pytest --durations=10

# Run with coverage (if pytest-cov installed)
python3 -m pytest --cov=solution test_meal_planner_pytest.py

Unittest (Original)

Run the original unittest suite with 27 tests:

python3 test_runner.py

Or run individual test modules:

python3 -m unittest test_meal_planner.py -v

File Structure

meal_planner/
├── solution.py                    # Main CLI application
├── test_meal_planner.py          # Original unittest suite (27 tests)
├── test_meal_planner_pytest.py   # Enhanced pytest suite (74 tests)  
├── test_runner.py                # Unittest runner script
├── run_pytest.py                 # Pytest runner script
├── pyproject.toml                # Pytest configuration
├── PYTEST_DOCS.md               # Detailed pytest documentation
└── README.md                     # This file

Requirements

  • Python 3.6+ (recommended: Python 3.8+)
  • pytest (optional, for enhanced testing): sudo apt-get install python3-pytest

Installation

  1. Clone or download the project files
  2. Install pytest (optional, for enhanced testing):
    sudo apt-get install python3-pytest
    # or
    pip3 install pytest
  3. Run the application:
    python3 solution.py --category breakfast --diet vegan

Error Handling

The application provides comprehensive error handling for:

  • Missing Arguments: When --category or --diet is not provided
  • Empty Input: When empty strings are provided for arguments
  • Invalid Categories: When non-existent meal categories are specified
  • Invalid Diets: When non-existent diet types are specified
  • No Meals Available: When a valid category-diet combination has no meals
  • Input Parsing: Handles various comma-separated input formats

Input Flexibility

The application accepts various input formats:

  • Case-insensitive: breakfast, BREAKFAST, Breakfast all work
  • Flexible spacing: "lunch, dinner", "lunch,dinner", " lunch , dinner " all work
  • Mixed case: "Lunch,DINNER,breakfast" works correctly

Development

The application follows clean code principles with:

  • Modular Design: Separate functions for validation, parsing, and meal suggestion
  • Comprehensive Error Handling: Detailed error messages for all failure cases
  • Extensive Test Coverage: 74 pytest tests covering all scenarios
  • Clear Documentation: Detailed docstrings and comments
  • Input Validation: Robust parsing and validation of user inputs
  • Order Preservation: Maintains user-specified order in results

For detailed pytest documentation and advanced testing features, see PYTEST_DOCS.md.

Contributing

When contributing to this project:

  1. Ensure all tests pass: python3 -m pytest test_meal_planner_pytest.py
  2. Add tests for new functionality
  3. Follow the existing code style and documentation patterns
  4. Update this README if adding new features or changing behavior

About

A meal plan suggestion application based on meal time and diet.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages