22import subprocess
33import time
44import tempfile
5- import json
65import socket
76from pathlib import Path
87
@@ -23,12 +22,11 @@ def before_scenario(context, scenario):
2322
2423 # Set up environment
2524 test_env = os .environ .copy ()
26- test_env ["TOWER_RUN_TIMEOUT" ] = "1 "
25+ test_env ["TOWER_RUN_TIMEOUT" ] = "3 "
2726
28- # Create mock config if tower_url is set
2927 if context .tower_url :
3028 test_env ["TOWER_URL" ] = context .tower_url
31- _setup_mock_config ( test_env , context . tower_url )
29+ test_env [ "TOWER_JWT" ] = "mock_jwt_token"
3230
3331 # Find a free port for this test scenario
3432 mcp_port = _find_free_port ()
@@ -38,7 +36,7 @@ def before_scenario(context, scenario):
3836 [tower_binary , "mcp-server" , "--port" , str (mcp_port )],
3937 env = test_env ,
4038 stdout = subprocess .DEVNULL ,
41- stderr = subprocess .PIPE ,
39+ stderr = subprocess .DEVNULL ,
4240 text = True
4341 )
4442
@@ -81,23 +79,6 @@ def _find_free_port():
8179 port = s .getsockname ()[1 ]
8280 return port
8381
84- def _setup_mock_config (test_env , tower_url ):
85- """Create a temporary tower configuration with mock session data"""
86- temp_config_dir = tempfile .mkdtemp (prefix = "tower_test_config_" )
87- test_env ["HOME" ] = temp_config_dir
88-
89- config_dir = os .path .join (temp_config_dir , ".config" , "tower" )
90- os .makedirs (config_dir , exist_ok = True )
91-
92- mock_session = {
93- "user" : {"id" : "mock_user_id" , "email" : "test@example.com" },
94- "teams" : [{"name" : "default" , "type" : "user" , "token" : {"jwt" : "mock_jwt_token" }}],
95- "active_team" : {"name" : "default" , "type" : "user" , "token" : {"jwt" : "mock_jwt_token" }},
96- "tower_url" : tower_url
97- }
98-
99- with open (os .path .join (config_dir , "session.json" ), 'w' ) as f :
100- json .dump (mock_session , f )
10182
10283def _find_tower_binary ():
10384 # Look for debug build first
0 commit comments