Skip to content

Commit 3a040f2

Browse files
author
LittleCoinCoin
committed
test(codex): fix Omni model field name in conversion test
Fixed test_codex_from_omni_conversion to use 'headers' instead of 'http_headers' when creating MCPServerConfigOmni instance. 'headers' is the universal field in Omni model that maps to 'http_headers' in Codex model during conversion. The test was using the wrong field name. test(codex-cli): fix tests to match Codex STDIO semantics Updated Codex CLI argument tests to align with official Codex documentation: - Removed invalid --header usage with STDIO servers (--command) - HTTP headers only apply to streamable HTTP servers (--url) - Updated test assertions to match STDIO-only fields - Fixed test to focus on shared arguments (cwd, tool filtering) Per Codex docs: STDIO servers don't support http_headers; only used with URL-based servers for authentication. test(mcp-cli): update parameter count for configure command Updated test expectations to match expanded handle_mcp_configure signature which now has 27 parameters (was 18) after adding Codex-specific arguments. Tests affected: - test_configure_argument_parsing_basic - test_configure_argument_parsing_with_options
1 parent 8ebf59f commit 3a040f2

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

tests/regression/test_mcp_codex_model_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_codex_from_omni_conversion(self):
6666
enabled_tools=["read"],
6767
disabled_tools=["write"],
6868
bearer_token_env_var="TOKEN",
69-
http_headers={"X-Test": "value"},
69+
headers={"X-Test": "value"}, # Universal field (maps to http_headers in Codex)
7070
env_http_headers={"X-Env": "VAR"},
7171
# Non-Codex fields (should be excluded)
7272
envFile="/path/to/env", # VS Code specific

tests/test_mcp_cli_all_host_specific_args.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ def test_all_codex_arguments_accepted(self, mock_stdout, mock_manager_class):
313313
mock_result.backup_path = None
314314
mock_manager.configure_server.return_value = mock_result
315315

316+
# Test STDIO server with Codex-specific STDIO fields
316317
result = handle_mcp_configure(
317318
host='codex',
318319
server_name='test-server',
@@ -325,9 +326,6 @@ def test_all_codex_arguments_accepted(self, mock_stdout, mock_manager_class):
325326
enabled=True,
326327
include_tools=['read', 'write'],
327328
exclude_tools=['delete'],
328-
bearer_token_env_var='FIGMA_OAUTH_TOKEN',
329-
header=['X-Custom=value'],
330-
env_header=['X-API-Key=API_KEY_VAR'],
331329
auto_approve=True
332330
)
333331

@@ -342,17 +340,14 @@ def test_all_codex_arguments_accepted(self, mock_stdout, mock_manager_class):
342340
server_config = call_args.kwargs['server_config']
343341
self.assertIsInstance(server_config, MCPServerConfigCodex)
344342

345-
# Verify Codex-specific fields
343+
# Verify Codex-specific STDIO fields
346344
self.assertEqual(server_config.env_vars, ['PATH', 'HOME'])
347345
self.assertEqual(server_config.cwd, '/workspace')
348346
self.assertEqual(server_config.startup_timeout_sec, 15)
349347
self.assertEqual(server_config.tool_timeout_sec, 120)
350348
self.assertTrue(server_config.enabled)
351349
self.assertEqual(server_config.enabled_tools, ['read', 'write'])
352350
self.assertEqual(server_config.disabled_tools, ['delete'])
353-
self.assertEqual(server_config.bearer_token_env_var, 'FIGMA_OAUTH_TOKEN')
354-
self.assertEqual(server_config.http_headers, {'X-Custom': 'value'})
355-
self.assertEqual(server_config.env_http_headers, {'X-API-Key': 'API_KEY_VAR'})
356351

357352
@patch('hatch.cli_hatch.MCPHostConfigurationManager')
358353
@patch('sys.stdout', new_callable=StringIO)
@@ -466,7 +461,7 @@ def test_codex_enabled_flag(self, mock_stdout, mock_manager_class):
466461
@patch('hatch.cli_hatch.MCPHostConfigurationManager')
467462
@patch('sys.stdout', new_callable=StringIO)
468463
def test_codex_reuses_shared_arguments(self, mock_stdout, mock_manager_class):
469-
"""Test that Codex reuses shared arguments (cwd, include-tools, exclude-tools, header)."""
464+
"""Test that Codex reuses shared arguments (cwd, include-tools, exclude-tools)."""
470465
mock_manager = MagicMock()
471466
mock_manager_class.return_value = mock_manager
472467

@@ -483,19 +478,17 @@ def test_codex_reuses_shared_arguments(self, mock_stdout, mock_manager_class):
483478
cwd='/workspace',
484479
include_tools=['tool1', 'tool2'],
485480
exclude_tools=['tool3'],
486-
header=['X-Custom=value'],
487481
auto_approve=True
488482
)
489483

490484
self.assertEqual(result, 0)
491485
call_args = mock_manager.configure_server.call_args
492486
server_config = call_args.kwargs['server_config']
493487

494-
# Verify shared arguments work for Codex
488+
# Verify shared arguments work for Codex STDIO servers
495489
self.assertEqual(server_config.cwd, '/workspace')
496490
self.assertEqual(server_config.enabled_tools, ['tool1', 'tool2'])
497491
self.assertEqual(server_config.disabled_tools, ['tool3'])
498-
self.assertEqual(server_config.http_headers, {'X-Custom': 'value'})
499492

500493

501494
if __name__ == '__main__':

tests/test_mcp_cli_direct_management.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@ def test_configure_argument_parsing_basic(self):
4040
try:
4141
result = main()
4242
# If main() returns without SystemExit, check the handler was called
43-
# Updated to include ALL host-specific parameters
43+
# Updated to include ALL host-specific parameters (27 total)
4444
mock_handler.assert_called_once_with(
4545
'claude-desktop', 'weather-server', 'python', ['weather.py'],
46-
None, None, None, None, False, None, None, None, None, None, None, False, False, False
46+
None, None, None, None, False, None, None, None, None, None, None,
47+
False, None, None, None, None, None, False, None, None, False, False, False
4748
)
4849
except SystemExit as e:
4950
# If SystemExit is raised, it should be 0 (success) and handler should have been called
5051
if e.code == 0:
5152
mock_handler.assert_called_once_with(
5253
'claude-desktop', 'weather-server', 'python', ['weather.py'],
53-
None, None, None, None, False, None, None, None, None, None, None, False, False, False
54+
None, None, None, None, False, None, None, None, None, None, None,
55+
False, None, None, None, None, None, False, None, None, False, False, False
5456
)
5557
else:
5658
self.fail(f"main() exited with code {e.code}, expected 0")
@@ -70,11 +72,12 @@ def test_configure_argument_parsing_with_options(self):
7072
with patch('hatch.cli_hatch.handle_mcp_configure', return_value=0) as mock_handler:
7173
try:
7274
main()
73-
# Updated to include ALL host-specific parameters
75+
# Updated to include ALL host-specific parameters (27 total)
7476
mock_handler.assert_called_once_with(
7577
'cursor', 'file-server', None, None,
7678
['API_KEY=secret', 'DEBUG=true'], 'http://localhost:8080',
77-
['Authorization=Bearer token'], None, False, None, None, None, None, None, None, True, True, True
79+
['Authorization=Bearer token'], None, False, None, None, None, None, None, None,
80+
False, None, None, None, None, None, False, None, None, True, True, True
7881
)
7982
except SystemExit as e:
8083
self.assertEqual(e.code, 0)

0 commit comments

Comments
 (0)