more adjustments
This commit is contained in:
@@ -4,33 +4,38 @@ from src import paths
|
||||
|
||||
# We mock App to avoid the heavy initialization logic
|
||||
class MockApp:
|
||||
def __init__(self):
|
||||
self.ui_conductor_dir = '/mock/conductor'
|
||||
self.ui_logs_dir = '/mock/logs'
|
||||
self.ui_scripts_dir = '/mock/scripts'
|
||||
self.config = {"paths": {}}
|
||||
self.ai_status = ""
|
||||
|
||||
from src.gui_2 import App
|
||||
_save_paths = App._save_paths
|
||||
def __init__(self):
|
||||
self.ui_conductor_dir = '/mock/conductor'
|
||||
self.ui_logs_dir = '/mock/logs'
|
||||
self.ui_scripts_dir = '/mock/scripts'
|
||||
self.config = {"paths": {}}
|
||||
self.ai_status = ""
|
||||
|
||||
def init_state(self):
|
||||
pass
|
||||
|
||||
from src.gui_2 import App
|
||||
_save_paths = App._save_paths
|
||||
|
||||
def test_save_paths():
|
||||
mock_app = MockApp()
|
||||
|
||||
with patch('src.models.save_config') as mock_save, \
|
||||
patch('shutil.copy') as mock_copy, \
|
||||
patch('src.paths.get_config_path') as mock_get_cfg, \
|
||||
patch('src.paths.reset_resolved') as mock_reset:
|
||||
|
||||
mock_get_cfg.return_value = MagicMock()
|
||||
mock_get_cfg.return_value.exists.return_value = True
|
||||
|
||||
mock_app.ui_conductor_dir = '/new/conductor'
|
||||
mock_app._save_paths()
|
||||
|
||||
# Verify config update
|
||||
assert mock_app.config['paths']['conductor_dir'] == '/new/conductor'
|
||||
mock_save.assert_called_once()
|
||||
mock_copy.assert_called_once()
|
||||
assert 'restart required' in mock_app.ai_status
|
||||
mock_reset.assert_called_once()
|
||||
mock_app = MockApp()
|
||||
|
||||
with patch('src.models.save_config') as mock_save, \
|
||||
patch('shutil.copy') as mock_copy, \
|
||||
patch('src.paths.get_config_path') as mock_get_cfg, \
|
||||
patch('src.paths.reset_resolved') as mock_reset, \
|
||||
patch.object(MockApp, 'init_state') as mock_init:
|
||||
|
||||
mock_get_cfg.return_value = MagicMock()
|
||||
mock_get_cfg.return_value.exists.return_value = True
|
||||
|
||||
mock_app.ui_conductor_dir = '/new/conductor'
|
||||
mock_app._save_paths()
|
||||
|
||||
# Verify config update
|
||||
assert 'conductor_dir' not in mock_app.config['paths']
|
||||
mock_save.assert_called_once()
|
||||
mock_copy.assert_called_once()
|
||||
assert 'applied' in mock_app.ai_status
|
||||
mock_reset.assert_called_once()
|
||||
mock_init.assert_called_once()
|
||||
|
||||
Reference in New Issue
Block a user