A command-line tool that provides meal suggestions based on category and diet preferences.
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).
- 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
python3 solution.py --category [category] --diet [diet]Single category and diet:
python3 solution.py --category breakfast --diet veganMultiple categories:
python3 solution.py --category "lunch,dinner,breakfast" --diet generalMultiple diets:
python3 solution.py --category lunch --diet "vegan,vegetarian"Multiple categories and diets:
python3 solution.py --category "breakfast,lunch" --diet "vegan,general"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
- 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.
- Breakfast: Morning meal options
- Lunch: Midday meal options
- Dinner: Evening meal options
- Snacks: Light meal and snack options
- 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
The application includes two comprehensive test suites:
Run the enhanced pytest suite with 74 comprehensive tests:
python3 -m pytest test_meal_planner_pytest.py -vRun with custom pytest runner for enhanced reporting:
python3 run_pytest.py- 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
# 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.pyRun the original unittest suite with 27 tests:
python3 test_runner.pyOr run individual test modules:
python3 -m unittest test_meal_planner.py -vmeal_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
- Python 3.6+ (recommended: Python 3.8+)
- pytest (optional, for enhanced testing):
sudo apt-get install python3-pytest
- Clone or download the project files
- Install pytest (optional, for enhanced testing):
sudo apt-get install python3-pytest # or pip3 install pytest - Run the application:
python3 solution.py --category breakfast --diet vegan
The application provides comprehensive error handling for:
- Missing Arguments: When
--categoryor--dietis 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
The application accepts various input formats:
- Case-insensitive:
breakfast,BREAKFAST,Breakfastall work - Flexible spacing:
"lunch, dinner","lunch,dinner"," lunch , dinner "all work - Mixed case:
"Lunch,DINNER,breakfast"works correctly
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.
When contributing to this project:
- Ensure all tests pass:
python3 -m pytest test_meal_planner_pytest.py - Add tests for new functionality
- Follow the existing code style and documentation patterns
- Update this README if adding new features or changing behavior