from agents.file_conversion import convert_csv_attachment_to_json from agents.goal_verifier import GoalVerifier def _goal(target: str = "e2e_metrics.json") -> str: return f"""Converti il file allegato e2e_metrics.csv in un nuovo file workspace chiamato {target}. Il JSON deve preservare tutti i valori del CSV. --- **File allegati:** ### 📎 e2e_metrics.csv (excel, 66B) ``` ## Foglio: Sheet1 mese,richieste,successi 1/1/26,12,11 2/1/26,15,14 3/1/26,18,17 ``` """ def test_convert_csv_attachment_to_json_preserves_rows_and_scalars(): result = convert_csv_attachment_to_json(_goal()) assert result is not None assert result.source_name == "e2e_metrics.csv" assert result.target_name == "e2e_metrics.json" assert result.row_count == 3 assert '"mese": "1/1/26"' in result.content assert '"richieste": 18' in result.content assert '"successi": 17' in result.content def test_convert_csv_attachment_requires_explicit_json_target(): assert convert_csv_attachment_to_json(_goal(target="output.txt")) is None def test_file_conversion_is_not_a_code_goal_even_with_e2e_marker(): assert GoalVerifier.is_code_goal(_goal()) is False def test_conversion_with_explicit_code_context_remains_code_goal(): assert GoalVerifier.is_code_goal( "Converti questo JSON in una funzione Python e scrivi il codice completo." ) is True def test_e2e_marker_alone_does_not_turn_file_reading_into_a_code_goal(): assert GoalVerifier.is_code_goal( "Leggi il file allegato e restituisci il marker E2E_FILE_READ_OK." ) is False assert GoalVerifier.is_code_goal( "Aggiungi un test e2e per l’endpoint API di conversione file." ) is True