-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_pipeline_inmemory.py
More file actions
48 lines (38 loc) · 1.34 KB
/
Copy pathtest_pipeline_inmemory.py
File metadata and controls
48 lines (38 loc) · 1.34 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
"""
tests/test_pipeline_inmemory.py
--------------------------------
Unit tests for execute_pipeline in-memory df_raw execution path.
"""
import sys
from pathlib import Path
import pandas as pd
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from src.pipeline import execute_pipeline
class TestPipelineInMemoryExecution:
"""Test suite for execute_pipeline in-memory execution mode."""
def test_execute_pipeline_with_df_raw(self, tmp_path):
out_csv = tmp_path / "inmemory_out.csv"
out_html = tmp_path / "inmemory_report.html"
df_raw = pd.DataFrame(
{
"id_venta": [1, 2, 2],
"fecha": ["2024-01-01", "2024-01-02", "2024-01-02"],
"precio": [10.0, 20.0, 20.0],
"cantidad": [2, 1, 1],
}
)
result = execute_pipeline(
output_path=out_csv,
report_path=out_html,
df_raw=df_raw,
normalize=True,
)
assert result.success is True
assert result.df_raw is not None
assert result.df_final is not None
assert len(result.df_final) == 2 # Duplicate removed
assert out_csv.exists()
assert out_html.exists()
assert "total" in result.df_final.columns
assert "precio_norm" in result.df_final.columns