test: Replace http server for recipes with nginx container

This commit is contained in:
Chris Coutinho
2025-10-17 04:30:03 +02:00
parent 2999d4b65e
commit 27519d0f62
5 changed files with 41 additions and 95 deletions
+6 -10
View File
@@ -153,21 +153,17 @@ async def test_cookbook_delete_nonexistent_recipe(nc_client: NextcloudClient):
logger.info(f"Delete correctly failed with {e.response.status_code}")
async def test_cookbook_import_recipe_from_url(
nc_client: NextcloudClient, test_recipe_server: str
):
async def test_cookbook_import_recipe_from_url(nc_client: NextcloudClient):
"""Test importing a recipe from a URL.
This is the key feature test - importing recipes from URLs using schema.org metadata.
Uses a local test server to provide reliable, controlled test data.
Uses an nginx container to serve reliable, controlled test data.
"""
docker_host = "host.docker.internal"
# Use the nginx container hostname within the Docker network
test_url = "http://recipes/black-pepper-tofu"
docker_accessible_url = test_recipe_server.replace("localhost", docker_host)
test_url = f"{docker_accessible_url}/black-pepper-tofu"
logger.info(f"Importing recipe from local test URL (Docker-accessible): {test_url}")
logger.info(f"Importing recipe from nginx container: {test_url}")
try:
imported_recipe = await nc_client.cookbook.import_recipe(test_url)
@@ -205,7 +201,7 @@ async def test_cookbook_import_recipe_from_url(
elif e.response.status_code == 400:
# URL couldn't be imported
logger.error(
f"Failed to import recipe from local test URL: {test_url}. "
f"Failed to import recipe from nginx container: {test_url}. "
f"Status: {e.response.status_code}, Response: {e.response.text}"
)
raise