-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_email_processor.bat
More file actions
81 lines (71 loc) · 2.19 KB
/
test_email_processor.bat
File metadata and controls
81 lines (71 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@echo off
REM Manual integration test: run pipeline, then send folder.
REM Requires config.yaml and EMAIL_PROCESSOR_TEST_RECIPIENT for send step.
chcp 65001 >nul
set PYTHONUTF8=1
setlocal
echo ========================================
echo Email Processor Testing Script
echo ========================================
echo.
REM Prefer venv Python if present
if exist ".venv\Scripts\python.exe" (
set "PYTHON_CMD=.venv\Scripts\python.exe"
) else (
set "PYTHON_CMD=py"
)
REM Step 1: Run full pipeline (fetch + send)
echo [1/3] Running full pipeline (fetch + send)...
echo ----------------------------------------
"%PYTHON_CMD%" -m email_processor run
if errorlevel 1 (
echo ERROR: Pipeline failed!
pause
exit /b 1
)
echo.
echo Pipeline completed successfully.
echo.
REM Step 2: Create test file for send-folder step
echo [2/3] Creating test file for send-folder...
echo ----------------------------------------
if not exist "send_folder" (
echo Creating send_folder...
mkdir send_folder
)
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /value 2^>nul') do set "datetime=%%I"
set "TEST_FILE=send_folder\test_%datetime:~0,8%_%datetime:~8,6%.txt"
echo Test file content > "%TEST_FILE%"
echo Created at: %date% %time% >> "%TEST_FILE%"
echo This is a test file for email sending. >> "%TEST_FILE%"
echo File path: %TEST_FILE% >> "%TEST_FILE%"
echo.
if not exist "%TEST_FILE%" (
echo ERROR: Failed to create test file.
pause
exit /b 1
)
echo Test file created: %TEST_FILE%
echo.
REM Step 3: Send folder (requires --to)
echo [3/3] Sending folder via SMTP...
echo ----------------------------------------
if not defined EMAIL_PROCESSOR_TEST_RECIPIENT (
echo ERROR: Set EMAIL_PROCESSOR_TEST_RECIPIENT before running send step.
echo Example: set EMAIL_PROCESSOR_TEST_RECIPIENT=you@example.com
pause
exit /b 1
)
"%PYTHON_CMD%" -m email_processor send folder send_folder --to "%EMAIL_PROCESSOR_TEST_RECIPIENT%"
if errorlevel 1 (
echo ERROR: Send folder failed!
pause
exit /b 1
)
echo.
echo Send folder completed successfully.
echo.
echo ========================================
echo All steps completed successfully.
echo ========================================
pause