import pandas as pd

from featureleak import LeakScanner


def test_detects_row_overlap_between_train_and_test():
    train_df = pd.DataFrame(
        {
            "sales": [10, 20, 30],
            "price": [1, 2, 3],
            "store": ["a", "b", "c"],
        }
    )

    test_df = pd.DataFrame(
        {
            "sales": [999, 888],
            "price": [2, 9],
            "store": ["b", "z"],
        }
    )

    full_df = pd.concat([train_df, test_df], ignore_index=True)

    scanner = LeakScanner()
    report = scanner.analyse(
        df=full_df,
        target="sales",
        train_df=train_df,
        test_df=test_df,
        show_summary=False,
    )

    assert any(issue.check == "train_test_contamination" for issue in report.issues)