From 4a3ab4042a5f1fb2797573a26e12b61279d20771 Mon Sep 17 00:00:00 2001 From: sstent Date: Mon, 29 Sep 2025 13:58:50 -0700 Subject: [PATCH] tryiong to fix the details page --- TDD_RULES.md | 29 +++++++++++++++++++++++++++++ tests/test_weekly_menu.py | 12 +++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 TDD_RULES.md diff --git a/TDD_RULES.md b/TDD_RULES.md new file mode 100644 index 0000000..ae2d11a --- /dev/null +++ b/TDD_RULES.md @@ -0,0 +1,29 @@ +# TDD Development Rules + +This document outlines the rules for Test-Driven Development (TDD) using pytest within our containerized environment. + +## Principles + +- **Test-First Approach**: All new features must begin with writing a failing test. +- **Debug-Driven Tests**: When a bug is identified during debugging, a new pytest must be created to reproduce the bug and validate its fix. + +## Pytest Execution + +Pytest should be run within the Docker Compose environment to ensure consistency and isolation. + +### Running Specific Tests + +To run tests for a specific file: + +```bash +docker compose build +docker compose run --remove-orphans foodtracker pytest tests/ +``` + +### Running All Tests + +To run all tests in the project: + +```bash +docker compose build +docker compose run --remove-orphans foodtracker pytest \ No newline at end of file diff --git a/tests/test_weekly_menu.py b/tests/test_weekly_menu.py index 84c384a..34c184c 100644 --- a/tests/test_weekly_menu.py +++ b/tests/test_weekly_menu.py @@ -7,11 +7,17 @@ import pytest class TestWeeklyMenuRoutes: """Test weekly menu-related routes""" - def test_get_weekly_menu_page(self, client): - """Test GET /weeklymenu page""" + def test_get_weekly_menu_page(self, client, sample_weekly_menu, sample_template): + """Test GET /weeklymenu page displays weekly menus correctly""" response = client.get("/weeklymenu") assert response.status_code == 200 - assert b"Weekly" in response.content or b"weekly" in response.content or b"Menu" in response.content + + # Check for the presence of the weekly menu name + assert sample_weekly_menu.name.encode('utf-8') in response.content + + # Check for the assigned templates' names + for weekly_menu_day in sample_weekly_menu.weekly_menu_days: + assert weekly_menu_day.template.name.encode('utf-8') in response.content def test_create_weekly_menu_route(self, client, sample_template):