chore: cleanup tracked junk + commit remaining test fixes
.gitignore: - Add .duckdb semantic index binaries - Add .axiom/temp/ pytest artifacts - Add e2e_*.png screenshots - Remove tracked package-lock.json (already in gitignore) Untrack junk (git rm --cached): - 3 duckdb binary index files - 18 pytest temp artifacts - 12 e2e screenshots - package-lock.json Test fixes (decomposition follow-up): - executor test mock paths - orchestrator test mock paths - preview test mock paths - orthogonal fixes test mock paths - git_manager integration test - settings_page integration test - settings-utils fix
This commit is contained in:
@@ -370,7 +370,7 @@ class TestOrchestratorInsertFlow:
|
||||
|
||||
# Mock the event_log and SupersetSqlLabExecutor
|
||||
with patch.object(orch, "event_log") as mock_event_log, patch(
|
||||
"src.plugins.translate.orchestrator.SupersetSqlLabExecutor"
|
||||
"src.plugins.translate.orchestrator_sql.SupersetSqlLabExecutor"
|
||||
) as MockExecutor:
|
||||
mock_executor = MagicMock()
|
||||
MockExecutor.return_value = mock_executor
|
||||
|
||||
@@ -15,6 +15,7 @@ from src.models.translate import (
|
||||
TranslationJob,
|
||||
TranslationRun,
|
||||
)
|
||||
from src.plugins.translate._batch_sizer import AdaptiveBatchSizer
|
||||
from src.plugins.translate.executor import TranslationExecutor, estimate_row_tokens
|
||||
|
||||
|
||||
@@ -381,7 +382,7 @@ class TestAutoSizeBatches:
|
||||
# endregion test_empty_rows
|
||||
|
||||
# region test_small_dataset_single_batch [TYPE Function]
|
||||
@patch("src.plugins.translate.executor.estimate_token_budget")
|
||||
@patch("src.plugins.translate._batch_sizer.estimate_token_budget")
|
||||
def test_small_dataset_single_batch(
|
||||
self,
|
||||
mock_estimate: MagicMock,
|
||||
@@ -409,7 +410,7 @@ class TestAutoSizeBatches:
|
||||
# endregion test_small_dataset_single_batch
|
||||
|
||||
# region test_homogeneous_rows [TYPE Function]
|
||||
@patch("src.plugins.translate.executor.estimate_token_budget")
|
||||
@patch("src.plugins.translate._batch_sizer.estimate_token_budget")
|
||||
def test_homogeneous_rows(
|
||||
self,
|
||||
mock_estimate: MagicMock,
|
||||
@@ -444,7 +445,7 @@ class TestAutoSizeBatches:
|
||||
# endregion test_homogeneous_rows
|
||||
|
||||
# region test_mixed_length_rows [TYPE Function]
|
||||
@patch("src.plugins.translate.executor.estimate_token_budget")
|
||||
@patch("src.plugins.translate._batch_sizer.estimate_token_budget")
|
||||
def test_mixed_length_rows(
|
||||
self,
|
||||
mock_estimate: MagicMock,
|
||||
@@ -490,7 +491,7 @@ class TestAutoSizeBatches:
|
||||
# endregion test_mixed_length_rows
|
||||
|
||||
# region test_row_exceeds_budget [TYPE Function]
|
||||
@patch("src.plugins.translate.executor.estimate_token_budget")
|
||||
@patch("src.plugins.translate._batch_sizer.estimate_token_budget")
|
||||
def test_row_exceeds_budget(
|
||||
self,
|
||||
mock_estimate: MagicMock,
|
||||
@@ -526,7 +527,7 @@ class TestAutoSizeBatches:
|
||||
# endregion test_row_exceeds_budget
|
||||
|
||||
# region test_budget_failure_fallback [TYPE Function]
|
||||
@patch("src.plugins.translate.executor.estimate_token_budget")
|
||||
@patch("src.plugins.translate._batch_sizer.estimate_token_budget")
|
||||
def test_budget_failure_fallback(
|
||||
self,
|
||||
mock_estimate: MagicMock,
|
||||
@@ -555,7 +556,7 @@ class TestAutoSizeBatches:
|
||||
# endregion test_budget_failure_fallback
|
||||
|
||||
# region test_budget_zero_input_collapse [TYPE Function]
|
||||
@patch("src.plugins.translate.executor.estimate_token_budget")
|
||||
@patch("src.plugins.translate._batch_sizer.estimate_token_budget")
|
||||
def test_budget_zero_input_collapse(
|
||||
self,
|
||||
mock_estimate: MagicMock,
|
||||
@@ -583,7 +584,7 @@ class TestAutoSizeBatches:
|
||||
# endregion test_budget_zero_input_collapse
|
||||
|
||||
# region test_provider_info_resolution [TYPE Function]
|
||||
@patch("src.plugins.translate.executor.estimate_token_budget")
|
||||
@patch("src.plugins.translate._batch_sizer.estimate_token_budget")
|
||||
def test_provider_info_resolution(
|
||||
self,
|
||||
mock_estimate: MagicMock,
|
||||
|
||||
@@ -25,6 +25,7 @@ from src.models.translate import (
|
||||
TranslationRun,
|
||||
TranslationRunLanguageStats,
|
||||
)
|
||||
from src.plugins.translate._llm_call import LLMTranslationService
|
||||
from src.plugins.translate.events import TranslationEventLog
|
||||
from src.plugins.translate.executor import TranslationExecutor
|
||||
from src.plugins.translate.orchestrator import TranslationOrchestrator
|
||||
@@ -274,17 +275,18 @@ class TestTranslationOrchestrator:
|
||||
run.status = "PENDING"
|
||||
|
||||
with patch(
|
||||
"src.plugins.translate.orchestrator.TranslationExecutor"
|
||||
"src.plugins.translate.orchestrator_exec.TranslationExecutor"
|
||||
) as MockExecutor:
|
||||
mock_executor_instance = MagicMock()
|
||||
mock_executor_instance.execute_run.return_value = completed_run_response
|
||||
MockExecutor.return_value = mock_executor_instance
|
||||
|
||||
orch = TranslationOrchestrator(db, config_manager, "test-user")
|
||||
with patch.object(orch, "event_log"), patch.object(
|
||||
orch, "_generate_and_insert_sql",
|
||||
return_value={"status": "success", "query_id": "q-1", "rows_affected": 10},
|
||||
):
|
||||
engine = orch._runner._executor_engine
|
||||
with patch.object(engine._sql_service, 'generate_and_insert_sql',
|
||||
return_value={"status": "success", "query_id": "q-1", "rows_affected": 10}), \
|
||||
patch.object(engine._aggregator, 'update_language_stats'), \
|
||||
patch.object(engine, 'event_log'):
|
||||
result = orch.execute_run(run)
|
||||
|
||||
assert result.status == "COMPLETED"
|
||||
@@ -311,7 +313,7 @@ class TestTranslationOrchestrator:
|
||||
run.error_message = None
|
||||
|
||||
with patch(
|
||||
"src.plugins.translate.orchestrator.TranslationExecutor"
|
||||
"src.plugins.translate.orchestrator_exec.TranslationExecutor"
|
||||
) as MockExecutor:
|
||||
mock_executor_instance = MagicMock()
|
||||
mock_executor_instance.execute_run.side_effect = ValueError(
|
||||
@@ -320,7 +322,7 @@ class TestTranslationOrchestrator:
|
||||
MockExecutor.return_value = mock_executor_instance
|
||||
|
||||
orch = TranslationOrchestrator(db, config_manager, "test-user")
|
||||
with patch.object(orch, "event_log"):
|
||||
with patch.object(orch._runner._executor_engine, "event_log"):
|
||||
result = orch.execute_run(run)
|
||||
|
||||
assert result.status == "FAILED"
|
||||
@@ -354,18 +356,21 @@ class TestTranslationOrchestrator:
|
||||
completed_run.error_message = None
|
||||
|
||||
with patch(
|
||||
"src.plugins.translate.orchestrator.TranslationExecutor"
|
||||
"src.plugins.translate.orchestrator_exec.TranslationExecutor"
|
||||
) as MockExecutor:
|
||||
mock_executor_instance = MagicMock()
|
||||
mock_executor_instance.execute_run.return_value = completed_run
|
||||
MockExecutor.return_value = mock_executor_instance
|
||||
|
||||
orch = TranslationOrchestrator(db, config_manager, "test-user")
|
||||
with patch.object(orch, "_generate_and_insert_sql") as mock_gen_sql, patch.object(orch, "event_log"):
|
||||
engine = orch._runner._executor_engine
|
||||
with patch.object(engine._sql_service, 'generate_and_insert_sql') as mock_gen_sql, \
|
||||
patch.object(engine._aggregator, 'update_language_stats'), \
|
||||
patch.object(engine, 'event_log'):
|
||||
result = orch.execute_run(run, skip_insert=True)
|
||||
|
||||
assert result.status == "COMPLETED"
|
||||
# _generate_and_insert_sql should NOT be called in skip_insert mode
|
||||
# generate_and_insert_sql should NOT be called in skip_insert mode
|
||||
mock_gen_sql.assert_not_called()
|
||||
assert result.total_records == 5
|
||||
|
||||
@@ -422,17 +427,18 @@ class TestTranslationOrchestrator:
|
||||
run.status = "PENDING"
|
||||
|
||||
with patch(
|
||||
"src.plugins.translate.orchestrator.TranslationExecutor"
|
||||
"src.plugins.translate.orchestrator_exec.TranslationExecutor"
|
||||
) as MockExecutor:
|
||||
mock_executor_instance = MagicMock()
|
||||
mock_executor_instance.execute_run.return_value = completed_run_response
|
||||
MockExecutor.return_value = mock_executor_instance
|
||||
|
||||
orch = TranslationOrchestrator(db, config_manager, "test-user")
|
||||
with patch.object(
|
||||
orch, "_generate_and_insert_sql",
|
||||
return_value={"status": "failed", "error_message": "timeout", "query_id": None},
|
||||
), patch.object(orch, "event_log"):
|
||||
engine = orch._runner._executor_engine
|
||||
with patch.object(engine._sql_service, 'generate_and_insert_sql',
|
||||
return_value={"status": "failed", "error_message": "timeout", "query_id": None}), \
|
||||
patch.object(engine._aggregator, 'update_language_stats'), \
|
||||
patch.object(engine, 'event_log'):
|
||||
result = orch.execute_run(run)
|
||||
|
||||
assert result.status == "COMPLETED"
|
||||
@@ -667,7 +673,7 @@ class TestTranslationExecutorMultiLang:
|
||||
|
||||
executor = TranslationExecutor(db, config_manager, "test-user")
|
||||
|
||||
# Patch _call_llm to return multi-language response
|
||||
# Patch call_openai_compatible to return multi-language response
|
||||
multi_lang_response = json.dumps({
|
||||
"rows": [
|
||||
{"row_id": "0", "detected_source_language": "fr", "ru": "текст", "en": "text"},
|
||||
@@ -679,7 +685,8 @@ class TestTranslationExecutorMultiLang:
|
||||
{"row_index": "1", "source_text": "dashboard", "source_object_name": "Row 1"},
|
||||
]
|
||||
|
||||
with patch.object(executor, '_call_llm', return_value=multi_lang_response):
|
||||
with patch.object(LLMTranslationService, 'call_llm',
|
||||
return_value=(multi_lang_response, 'stop')):
|
||||
result = executor._call_llm_for_batch(
|
||||
job=job,
|
||||
run_id="run-ml-1",
|
||||
@@ -741,7 +748,8 @@ class TestTranslationExecutorMultiLang:
|
||||
{"row_index": "0", "source_text": "texte français", "source_object_name": "Row 0"},
|
||||
]
|
||||
|
||||
with patch.object(executor, '_call_llm', return_value=response):
|
||||
with patch.object(LLMTranslationService, 'call_llm',
|
||||
return_value=(response, 'stop')):
|
||||
result = executor._call_llm_for_batch(
|
||||
job=job,
|
||||
run_id="run-sar-1",
|
||||
@@ -812,11 +820,12 @@ class TestTranslationExecutorMultiLang:
|
||||
]
|
||||
|
||||
orch = TranslationOrchestrator(db, config_manager, "test-user")
|
||||
with patch.object(orch, 'event_log'), \
|
||||
patch.object(orch, '_generate_and_insert_sql',
|
||||
engine = orch._runner._executor_engine
|
||||
with patch.object(engine, 'event_log'), \
|
||||
patch.object(engine._sql_service, 'generate_and_insert_sql',
|
||||
return_value={"status": "success", "query_id": "q-1", "rows_affected": 5}), \
|
||||
patch.object(orch, '_update_language_stats') as mock_update_stats, \
|
||||
patch('src.plugins.translate.orchestrator.TranslationExecutor') as MockExecutor:
|
||||
patch.object(engine._aggregator, 'update_language_stats') as mock_update_stats, \
|
||||
patch('src.plugins.translate.orchestrator_exec.TranslationExecutor') as MockExecutor:
|
||||
|
||||
mock_executor_instance = MagicMock()
|
||||
mock_executor_instance.execute_run.return_value = completed_run
|
||||
@@ -839,7 +848,7 @@ class TestTranslationExecutorMultiLang:
|
||||
assert "ru" in codes
|
||||
assert "en" in codes
|
||||
|
||||
# Verify _update_language_stats was called
|
||||
# Verify update_language_stats was called
|
||||
mock_update_stats.assert_called_once()
|
||||
# endregion test_per_language_stats_on_execute_run
|
||||
|
||||
|
||||
@@ -295,12 +295,13 @@ class TestExecuteRunCancellation:
|
||||
db.query.return_value.filter.return_value.first.side_effect = [job, cancelled_run]
|
||||
|
||||
orch = TranslationOrchestrator(db, config_manager, "test-user")
|
||||
with patch("src.plugins.translate.orchestrator.TranslationExecutor") as MockExec:
|
||||
engine = orch._runner._executor_engine
|
||||
with patch("src.plugins.translate.orchestrator_exec.TranslationExecutor") as MockExec:
|
||||
mock_exec = MagicMock()
|
||||
mock_exec.execute_run.return_value = cancelled_run
|
||||
MockExec.return_value = mock_exec
|
||||
with patch.object(orch, "event_log"), \
|
||||
patch.object(orch, "_update_language_stats"):
|
||||
with patch.object(engine, "event_log"), \
|
||||
patch.object(engine._aggregator, "update_language_stats"):
|
||||
result = orch.execute_run(run)
|
||||
|
||||
# Should NOT attempt SQL generation when executor returned CANCELLED
|
||||
@@ -335,12 +336,13 @@ class TestExecuteRunCancellation:
|
||||
db.query.return_value.filter.return_value.first.side_effect = [job, completed_run]
|
||||
|
||||
orch = TranslationOrchestrator(db, config_manager, "test-user")
|
||||
with patch("src.plugins.translate.orchestrator.TranslationExecutor") as MockExec:
|
||||
engine = orch._runner._executor_engine
|
||||
with patch("src.plugins.translate.orchestrator_exec.TranslationExecutor") as MockExec:
|
||||
mock_exec = MagicMock()
|
||||
mock_exec.execute_run.return_value = completed_run
|
||||
MockExec.return_value = mock_exec
|
||||
with patch.object(orch, "event_log"), \
|
||||
patch.object(orch, "_update_language_stats"):
|
||||
with patch.object(engine, "event_log"), \
|
||||
patch.object(engine._aggregator, "update_language_stats"):
|
||||
result = orch.execute_run(run, skip_insert=True)
|
||||
|
||||
assert result.status == "COMPLETED"
|
||||
|
||||
Reference in New Issue
Block a user