Loading pkgs/by-name/mc/mcp-nixos/package.nix +8 −19 Original line number Diff line number Diff line Loading @@ -6,21 +6,16 @@ python3Packages.buildPythonApplication rec { pname = "mcp-nixos"; version = "1.0.3"; version = "2.1.0"; pyproject = true; src = fetchFromGitHub { owner = "utensils"; repo = "mcp-nixos"; tag = "v${version}"; hash = "sha256-UCsJ8eDuHL14u2GFIYEY/drtZ6jht5zN/G/6QNlEy2g="; hash = "sha256-rnpIDY/sy/uV+1dsW+MrFwAFE/RHg5K/6aa5k7Yt1Dc="; }; patches = [ # This patch mocks nix channel listing network calls in tests ./tests-mock-nix-channels.patch ]; build-system = [ python3Packages.hatchling ]; dependencies = with python3Packages; [ Loading @@ -30,8 +25,6 @@ python3Packages.buildPythonApplication rec { requests ]; pythonRelaxDeps = [ "fastmcp" ]; nativeCheckInputs = with python3Packages; [ anthropic pytestCheckHook Loading @@ -39,18 +32,14 @@ python3Packages.buildPythonApplication rec { python-dotenv ]; disabledTestMarks = [ # Require network access "integration" disabledTestPaths = [ # Requires network access "tests/test_integration.py" ]; disabledTestPaths = [ # Require network access "tests/test_nixhub.py" "tests/test_mcp_behavior.py" "tests/test_options.py" # Requires configured channels "tests/test_channels.py" disabledTests = [ # Requires network access "test_valid_channel" ]; pythonImportsCheck = [ "mcp_nixos" ]; Loading pkgs/by-name/mc/mcp-nixos/tests-mock-nix-channels.patchdeleted 100644 → 0 +0 −32 Original line number Diff line number Diff line diff --git a/tests/conftest.py b/tests/conftest.py index baae124..2b4bf01 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,27 @@ """Minimal test configuration for refactored MCP-NixOS.""" +import pytest +@pytest.fixture(autouse=True) +def mock_get_channels(monkeypatch): + """Mock get_channels function to return fixed channels for all tests.""" + def mock_channels(): + return { + "unstable": "latest-43-nixos-unstable", + "25.05": "latest-43-nixos-25.05", + "25.11": "latest-43-nixos-25.11", + "24.11": "latest-43-nixos-24.11", + "stable": "latest-43-nixos-25.05", + "beta": "latest-43-nixos-25.05" + } + + # Patch the function in the server module + monkeypatch.setattr('mcp_nixos.server.get_channels', mock_channels) + + # Also patch any imported references in test modules + monkeypatch.setattr('tests.test_server.get_channels', mock_channels) + + def pytest_addoption(parser): """Add test filtering options.""" parser.addoption("--unit", action="store_true", help="Run unit tests only") Loading
pkgs/by-name/mc/mcp-nixos/package.nix +8 −19 Original line number Diff line number Diff line Loading @@ -6,21 +6,16 @@ python3Packages.buildPythonApplication rec { pname = "mcp-nixos"; version = "1.0.3"; version = "2.1.0"; pyproject = true; src = fetchFromGitHub { owner = "utensils"; repo = "mcp-nixos"; tag = "v${version}"; hash = "sha256-UCsJ8eDuHL14u2GFIYEY/drtZ6jht5zN/G/6QNlEy2g="; hash = "sha256-rnpIDY/sy/uV+1dsW+MrFwAFE/RHg5K/6aa5k7Yt1Dc="; }; patches = [ # This patch mocks nix channel listing network calls in tests ./tests-mock-nix-channels.patch ]; build-system = [ python3Packages.hatchling ]; dependencies = with python3Packages; [ Loading @@ -30,8 +25,6 @@ python3Packages.buildPythonApplication rec { requests ]; pythonRelaxDeps = [ "fastmcp" ]; nativeCheckInputs = with python3Packages; [ anthropic pytestCheckHook Loading @@ -39,18 +32,14 @@ python3Packages.buildPythonApplication rec { python-dotenv ]; disabledTestMarks = [ # Require network access "integration" disabledTestPaths = [ # Requires network access "tests/test_integration.py" ]; disabledTestPaths = [ # Require network access "tests/test_nixhub.py" "tests/test_mcp_behavior.py" "tests/test_options.py" # Requires configured channels "tests/test_channels.py" disabledTests = [ # Requires network access "test_valid_channel" ]; pythonImportsCheck = [ "mcp_nixos" ]; Loading
pkgs/by-name/mc/mcp-nixos/tests-mock-nix-channels.patchdeleted 100644 → 0 +0 −32 Original line number Diff line number Diff line diff --git a/tests/conftest.py b/tests/conftest.py index baae124..2b4bf01 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,27 @@ """Minimal test configuration for refactored MCP-NixOS.""" +import pytest +@pytest.fixture(autouse=True) +def mock_get_channels(monkeypatch): + """Mock get_channels function to return fixed channels for all tests.""" + def mock_channels(): + return { + "unstable": "latest-43-nixos-unstable", + "25.05": "latest-43-nixos-25.05", + "25.11": "latest-43-nixos-25.11", + "24.11": "latest-43-nixos-24.11", + "stable": "latest-43-nixos-25.05", + "beta": "latest-43-nixos-25.05" + } + + # Patch the function in the server module + monkeypatch.setattr('mcp_nixos.server.get_channels', mock_channels) + + # Also patch any imported references in test modules + monkeypatch.setattr('tests.test_server.get_channels', mock_channels) + + def pytest_addoption(parser): """Add test filtering options.""" parser.addoption("--unit", action="store_true", help="Run unit tests only")