27 lines
758 B
Python
27 lines
758 B
Python
from __future__ import annotations
|
|
|
|
import pandas as pd
|
|
|
|
from manesh_trader.exporting import df_for_export
|
|
|
|
|
|
def test_df_for_export_handles_named_datetime_index() -> None:
|
|
idx = pd.date_range("2025-01-01", periods=2, freq="D", name="Date")
|
|
df = pd.DataFrame({"Close": [100.0, 101.0]}, index=idx)
|
|
|
|
out = df_for_export(df)
|
|
|
|
assert "timestamp" in out.columns
|
|
assert "Date" not in out.columns
|
|
assert isinstance(out.loc[0, "timestamp"], str)
|
|
|
|
|
|
def test_df_for_export_handles_unnamed_index() -> None:
|
|
idx = pd.date_range("2025-01-01", periods=2, freq="D")
|
|
df = pd.DataFrame({"Close": [100.0, 101.0]}, index=idx)
|
|
|
|
out = df_for_export(df)
|
|
|
|
assert "timestamp" in out.columns
|
|
assert isinstance(out.loc[0, "timestamp"], str)
|