MCPcopy Create free account
hub / github.com/IBM/mcp-cli / test_process_options_with_servers

Function test_process_options_with_servers

tests/config/test_cli_options.py:155–196  ·  view source on GitHub ↗
(mock_discovery, dummy_config_file, monkeypatch)

Source from the content-addressed store, hash-verified

153
154@patch("mcp_cli.config.cli_options.trigger_discovery_after_setup")
155def test_process_options_with_servers(mock_discovery, dummy_config_file, monkeypatch):
156 # Mock discovery to avoid actual network calls
157 mock_discovery.return_value = 0
158
159 # Prepare inputs.
160 # server: a comma-separated string.
161 server_input = "Server1, Server2"
162 disable_filesystem = False
163 provider = "openai"
164 model = "custom-model"
165
166 # Clear any preexisting environment variables for a clean test.
167 monkeypatch.delenv("LLM_PROVIDER", raising=False)
168 monkeypatch.delenv("LLM_MODEL", raising=False)
169 monkeypatch.delenv("SOURCE_FILESYSTEMS", raising=False)
170
171 servers_list, user_specified, server_names = process_options(
172 server=server_input,
173 disable_filesystem=disable_filesystem,
174 provider=provider,
175 model=model,
176 config_file=dummy_config_file,
177 )
178
179 # Check that server list and user_specified were parsed correctly.
180 assert servers_list == ["Server1", "Server2"]
181 assert user_specified == ["Server1", "Server2"]
182
183 # In the dummy config, the keys are "Server1" and "Server2". Because the user specified
184 # these names, extract_server_names should only include those that match.
185 # Mapping is based on order as encountered from the specified servers.
186 expected_mapping = {0: "Server1", 1: "Server2"}
187 assert server_names == expected_mapping
188
189 # Check environment variables.
190 assert os.environ["LLM_PROVIDER"] == provider
191 assert os.environ["LLM_MODEL"] == model
192
193 # Since disable_filesystem is False, SOURCE_FILESYSTEMS should be set.
194 source_fs = json.loads(os.environ["SOURCE_FILESYSTEMS"])
195 # For testing, we expect at least the current working directory.
196 assert os.getcwd() in source_fs
197
198
199@patch("mcp_cli.config.cli_options.trigger_discovery_after_setup")

Callers

nothing calls this directly

Calls 1

process_optionsFunction · 0.90

Tested by

no test coverage detected