Team Ai
Apppublic

IDKHowToCodeFr/tinyml-backend

sourceHugging Faceupdated 13h agoView on Hugging Face
1likes
test_preprocessing.py43 linesDownload Raw Back to tests
1import pytest2import pandas as pd3import numpy as np4import os5import sys6 7sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../backend')))8from preprocessing import preprocess_data, resolve_model_dir9 10def test_resolve_model_dir():11    md = resolve_model_dir()12    assert md.endswith("model")13 14def test_preprocess_data_training():15    df = pd.DataFrame({16        'Heart Rate (bpm)': [80, 90, np.nan],17        'SpO2 Level (%)': [98, 97, 95],18        'Systolic Blood Pressure (mmHg)': [120, 125, 130],19        'Diastolic Blood Pressure (mmHg)': [80, 85, 90],20        'Body Temperature (°C)': [37.0, 37.2, 37.5],21        'Predicted Disease': ['Normal', 'Asthma', 'Normal']22    })23    24    X, y = preprocess_data(df, is_training=True)25    26    assert not X.isnull().values.any()27    assert len(y) == 328    assert 'Risk_Severity' in X.columns29 30def test_preprocess_data_inference():31    df = pd.DataFrame({32        'Heart Rate (bpm)': [100],33        'SpO2 Level (%)': [99],34        'Systolic Blood Pressure (mmHg)': [120],35        'Diastolic Blood Pressure (mmHg)': [80],36        'Body Temperature (°C)': [37.0],37    })38    39    X, y = preprocess_data(df, is_training=False)40    41    assert y is None42    assert 'Risk_Severity' in X.columns43