# Path: pyani/anim.py
# class PyaniANImException(PyaniException):
# def get_fasta_files(dirname: Path = Path(".")) -> Iterable:
# def get_version(nucmer_exe: Path = pyani_config.NUCMER_DEFAULT) -> str:
# def generate_nucmer_jobs(
#     filenames: List[Path],
#     outdir: Path = Path("."),
#     nucmer_exe: Path = pyani_config.NUCMER_DEFAULT,
#     filter_exe: Path = pyani_config.FILTER_DEFAULT,
#     maxmatch: bool = False,
#     jobprefix: str = "ANINUCmer",
# ):
# def generate_nucmer_commands(
#     filenames: List[Path],
#     outdir: Path = Path("."),
#     nucmer_exe: Path = pyani_config.NUCMER_DEFAULT,
#     filter_exe: Path = pyani_config.FILTER_DEFAULT,
#     maxmatch: bool = False,
# ) -> Tuple[List, List]:
# def construct_nucmer_cmdline(
#     fname1: Path,
#     fname2: Path,
#     outdir: Path = Path("."),
#     nucmer_exe: Path = pyani_config.NUCMER_DEFAULT,
#     filter_exe: Path = pyani_config.FILTER_DEFAULT,
#     maxmatch: bool = False,
# ) -> Tuple[str, str]:
# def parse_delta(filename: Path) -> Tuple[int, int]:
# def process_deltadir(
#     delta_dir: Path, org_lengths: Dict, logger: Optional[Logger] = None
# ) -> ANIResults:
# 
# Path: pyani/pyani_files.py
# class PyaniFilesException(PyaniException):
# def get_fasta_files(dirname: Path = Path(".")) -> List[Path]:
# def get_fasta_paths(
#     dirname: Path = Path("."), extlist: Optional[List] = None
# ) -> List[Path]:
# def get_fasta_and_hash_paths(dirname: Path = Path(".")) -> List[Tuple[Path, Path]]:
# def get_input_files(dirname: Path, *ext) -> List[Path]:
# def get_sequence_lengths(fastafilenames: Iterable[Path]) -> Dict[str, int]:
# def read_hash_string(filename: Path) -> Tuple[str, str]:
# def read_fasta_description(filename: Path) -> str:
# def load_classes_labels(path: Path) -> Dict[str, str]:
# def collect_existing_output(dirpath: Path, program: str, args: Namespace) -> List[Path]:


from pathlib import Path
from typing import List, NamedTuple, Tuple
from pandas.testing import assert_frame_equal
from pyani import anim, pyani_files
import pandas as pd
import pytest
import unittest

# Test case 3: there is an executable file, but the version can't be retrieved
def test_get_version_exe_no_version(executable_without_version):
    """Test behaviour when the version for the executable can not be retrieved."""
    test_file_3 = Path("/missing/version/nucmer")
    assert (
        anim.get_version(test_file_3)
        == f"nucmer exists at {test_file_3} but could not retrieve version"
    )


# Test regex for different NUCmer versions
def test_get_version_nucmer_3(mock_get_nucmer_3_version):
    """Tests the regex that gets the version number for NUCmer <= 3."""
    fake_nucmer_3 = Path("/fake/nucmer3/executable")

    assert anim.get_version(fake_nucmer_3) == f"Darwin_3.1 ({fake_nucmer_3})"


def test_get_version_nucmer_4(mock_get_nucmer_4_version):
    """Tests the regex that gets the version number for NUCmer 4."""
    fake_nucmer_4 = Path("/fake/nucmer4/executable")

    assert anim.get_version(fake_nucmer_4) == f"Darwin_4.0.0rc1 ({fake_nucmer_4})"


# Test .delta output file processing
def test_deltadir_parsing(delta_output_dir):
    """Process test directory of .delta files into ANIResults."""
    seqfiles = pyani_files.get_fasta_files(delta_output_dir.seqdir)

# Path: pyani/anim.py
# class PyaniANImException(PyaniException):
# def get_fasta_files(dirname: Path = Path(".")) -> Iterable:
# def get_version(nucmer_exe: Path = pyani_config.NUCMER_DEFAULT) -> str:
# def generate_nucmer_jobs(
#     filenames: List[Path],
#     outdir: Path = Path("."),
#     nucmer_exe: Path = pyani_config.NUCMER_DEFAULT,
#     filter_exe: Path = pyani_config.FILTER_DEFAULT,
#     maxmatch: bool = False,
#     jobprefix: str = "ANINUCmer",
# ):
# def generate_nucmer_commands(
#     filenames: List[Path],
#     outdir: Path = Path("."),
#     nucmer_exe: Path = pyani_config.NUCMER_DEFAULT,
#     filter_exe: Path = pyani_config.FILTER_DEFAULT,
#     maxmatch: bool = False,
# ) -> Tuple[List, List]:
# def construct_nucmer_cmdline(
#     fname1: Path,
#     fname2: Path,
#     outdir: Path = Path("."),
#     nucmer_exe: Path = pyani_config.NUCMER_DEFAULT,
#     filter_exe: Path = pyani_config.FILTER_DEFAULT,
#     maxmatch: bool = False,
# ) -> Tuple[str, str]:
# def parse_delta(filename: Path) -> Tuple[int, int]:
# def process_deltadir(
#     delta_dir: Path, org_lengths: Dict, logger: Optional[Logger] = None
# ) -> ANIResults:
# 
# Path: pyani/pyani_files.py
# class PyaniFilesException(PyaniException):
# def get_fasta_files(dirname: Path = Path(".")) -> List[Path]:
# def get_fasta_paths(
#     dirname: Path = Path("."), extlist: Optional[List] = None
# ) -> List[Path]:
# def get_fasta_and_hash_paths(dirname: Path = Path(".")) -> List[Tuple[Path, Path]]:
# def get_input_files(dirname: Path, *ext) -> List[Path]:
# def get_sequence_lengths(fastafilenames: Iterable[Path]) -> Dict[str, int]:
# def read_hash_string(filename: Path) -> Tuple[str, str]:
# def read_fasta_description(filename: Path) -> str:
# def load_classes_labels(path: Path) -> Dict[str, str]:
# def collect_existing_output(dirpath: Path, program: str, args: Namespace) -> List[Path]:


# Path: tests/test_anim.py
from pathlib import Path
from typing import List, NamedTuple, Tuple
from pandas.testing import assert_frame_equal
from pyani import anim, pyani_files
import pandas as pd
import pytest
import unittest


# Test case 3: there is an executable file, but the version can't be retrieved
def test_get_version_exe_no_version(executable_without_version):
    """Test behaviour when the version for the executable can not be retrieved."""
    test_file_3 = Path("/missing/version/nucmer")
    assert (
        anim.get_version(test_file_3)
        == f"nucmer exists at {test_file_3} but could not retrieve version"
    )


# Test regex for different NUCmer versions
def test_get_version_nucmer_3(mock_get_nucmer_3_version):
    """Tests the regex that gets the version number for NUCmer <= 3."""
    fake_nucmer_3 = Path("/fake/nucmer3/executable")

    assert anim.get_version(fake_nucmer_3) == f"Darwin_3.1 ({fake_nucmer_3})"


def test_get_version_nucmer_4(mock_get_nucmer_4_version):
    """Tests the regex that gets the version number for NUCmer 4."""
    fake_nucmer_4 = Path("/fake/nucmer4/executable")

    assert anim.get_version(fake_nucmer_4) == f"Darwin_4.0.0rc1 ({fake_nucmer_4})"


# Test .delta output file processing
def test_deltadir_parsing(delta_output_dir):
    """Process test directory of .delta files into ANIResults."""
    seqfiles = pyani_files.get_fasta_files(delta_output_dir.seqdir)

    orglengths = pyani_files.get_sequence_lengths(seqfiles)