recipe links

This commit is contained in:
Joren de Graaf
2026-10-23 14:30:58 +02:00
parent 5b986134be
commit 4d76a2bc9c
52 changed files with 2698 additions and 19 deletions
+14
View File
@@ -8,6 +8,7 @@ from django.conf import settings
from food.models import FoodProduct
from food.api import create_token
from home_assistant.models import HomeAssistantConnection
from recipes.models import Recipe, RecipeIngredient
from .models import GroceryItem
from .services import GroceryError, add, add_purchased_to_inventory, apply_recipe, edit, recipe_preview, search
@@ -71,6 +72,19 @@ class GroceryTests(TestCase):
RecipeIngredient.objects.create(recipe=recipe, name='Water', quantity=200, unit='ml')
self.assertContains(self.client.get(f'/groceries/recipe/{recipe.api_id}/preview/'), 'Review groceries')
@override_settings(MIDDLEWARE=[item for item in settings.MIDDLEWARE if not item.startswith('whitenoise.')],
SECURE_SSL_REDIRECT=False)
def test_grocery_page_shows_home_assistant_sync_action_when_list_is_configured(self):
self.client.force_login(self.user)
response = self.client.get('/groceries/')
self.assertNotContains(response, 'Sync with Home Assistant')
HomeAssistantConnection.objects.create(user=self.user, base_url='https://ha.example',
encrypted_token='encrypted', grocery_entity_id='todo.shopping')
response = self.client.get('/groceries/')
self.assertContains(response, 'Sync with Home Assistant')
self.assertContains(response, 'Review changes before confirming.')
self.assertContains(response, 'href="/settings/home-assistant/preview/"')
def test_inventory_transfer_requires_purchase_and_is_single_use(self):
item = add(self.user, name='Rice', quantity='500', unit='g')
product = FoodProduct.objects.create(owner=self.user, product_name='Rice')