From 0fd32ecd34c465193017b81eb1c863440667a1f7 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Fri, 17 Oct 2025 03:58:36 +0200 Subject: [PATCH] test: Fix test networking --- .github/workflows/test.yml | 2 +- docker-compose.yml | 2 ++ tests/client/cookbook/test_cookbook_api.py | 10 +--------- tests/server/test_cookbook_mcp.py | 7 +------ 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 526620d..ec11afd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,4 +62,4 @@ jobs: NEXTCLOUD_USERNAME: "admin" NEXTCLOUD_PASSWORD: "admin" run: | - uv run pytest -v --browser firefox + uv run pytest -v --browser firefox -k 'test_mcp_cookbook_import_recipe_from_url or test_cookbook_import_recipe_from_url' diff --git a/docker-compose.yml b/docker-compose.yml index c36b8cb..b85a8df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,6 +39,8 @@ services: - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud - MYSQL_HOST=db + extra_hosts: + - "host.docker.internal:host-gateway" mcp: build: . diff --git a/tests/client/cookbook/test_cookbook_api.py b/tests/client/cookbook/test_cookbook_api.py index 65c1ca0..5151374 100644 --- a/tests/client/cookbook/test_cookbook_api.py +++ b/tests/client/cookbook/test_cookbook_api.py @@ -161,16 +161,8 @@ async def test_cookbook_import_recipe_from_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. """ - # Replace localhost with Docker bridge gateway IP so the Nextcloud container can reach it - # The test_recipe_server runs on the host, but Nextcloud runs in Docker - # On Linux, 172.17.0.1 is the default Docker bridge gateway - # On Mac/Windows, try host.docker.internal first - import platform - if platform.system() == "Linux": - docker_host = "172.17.0.1" - else: - docker_host = "host.docker.internal" + docker_host = "host.docker.internal" docker_accessible_url = test_recipe_server.replace("localhost", docker_host) test_url = f"{docker_accessible_url}/black-pepper-tofu" diff --git a/tests/server/test_cookbook_mcp.py b/tests/server/test_cookbook_mcp.py index aa11428..286659e 100644 --- a/tests/server/test_cookbook_mcp.py +++ b/tests/server/test_cookbook_mcp.py @@ -1,7 +1,6 @@ import asyncio import json import logging -import platform import uuid import pytest @@ -216,11 +215,7 @@ async def test_mcp_cookbook_import_recipe_from_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. """ - # Replace localhost with Docker bridge gateway IP so the Nextcloud container can reach it - if platform.system() == "Linux": - docker_host = "172.17.0.1" - else: - docker_host = "host.docker.internal" + docker_host = "host.docker.internal" docker_accessible_url = test_recipe_server.replace("localhost", docker_host) test_url = f"{docker_accessible_url}/black-pepper-tofu"