from pathlib import Path

import pytest

import msastats


def test_stats_names_matches_expected_order():
    names = msastats.stats_names()
    assert isinstance(names, list)
    assert names[0] == "AVG_GAP_SIZE"
    assert names[-1] == "MSA_POSITION_WITH_N_MINUS_1_GAPS"
    assert len(names) == 27


def test_calculate_fasta_stats_matches_ground_truth():
    fasta_path = Path(__file__).parent / "msas" / "dummy_msa.fasta"
    stats = msastats.calculate_fasta_stats(fasta_path)
    assert isinstance(stats, list)
    assert len(stats) == 27
    assert stats[0] == pytest.approx(2.71, 1e-2)
    assert stats[1] == 37.0
    assert stats[-1] == 13.0


def test_calculate_msa_stats_smoke():
    stats = msastats.calculate_msa_stats(["AA-A", "AA-A", "A--A"])
    assert isinstance(stats, list)
    assert len(stats) == 27

