#!/usr/bin/env python3
"""Simple test for MultiMolDesc functionality"""

from pathlib import Path
from qspoc.descriptor import QSPOCDesc
from test_utils import BaseTestCase, MultiMolTestMixin

Multiwfn_path = Path(__file__).parent.parent / "bin/Multiwfn/Multiwfn_3.8_bin_Linux_noGUI/Multiwfn_noGUI"


class TestMultiSimple(BaseTestCase, MultiMolTestMixin):
    """Simple test for MultiMolDesc"""

    def test_with_xtb_opt_xtb_sp_xtb_cdft(self):
        """Test basic MultiMolDesc functionality"""
        self.print_test_header("xtb opt, xtb sp, xtb cdft")

        wd = Path(__file__).parent

        qspoc = QSPOCDesc(multiwfn_path=Multiwfn_path, save_dir=wd / "test_file/test1", exe_path_dict={"xtb": "xtb", "g16": "g16"})
        qspoc.load_data_from_file(file_path=wd / "test_file/input_test_simple.csv")
        qspoc.get_init_sturct()
        qspoc.geometric_opt(method="xtb")
        qspoc.singlepoint_energy(method="xtb")
        qspoc.descriptor_calc(version="stem", cdft_command="xtb")

    def test_with_xtb_opt_xtb_sp(self):
        """Test basic MultiMolDesc functionality"""
        self.print_test_header("xtb opt, xtb sp, g16 cdft")

        wd = Path(__file__).parent

        qspoc = QSPOCDesc(multiwfn_path=Multiwfn_path, save_dir=wd / "test_file/test2", exe_path_dict={"xtb": "xtb", "g16": "g16"})
        qspoc.load_data_from_file(file_path=wd / "test_file/input_test_simple.csv")
        qspoc.get_init_sturct()
        qspoc.geometric_opt(method="xtb")
        qspoc.singlepoint_energy(method="xtb")
        qspoc.descriptor_calc(version="stem", cdft_command="b3lyp/def2tzvp")

    def test_with_xtb_opt_g16_sp(self):
        """Test basic MultiMolDesc functionality"""
        self.print_test_header("xtb opt, g16 sp, g16 cdft")

        wd = Path(__file__).parent

        qspoc = QSPOCDesc(multiwfn_path=Multiwfn_path, save_dir=wd / "test_file/test3", exe_path_dict={"xtb": "xtb", "g16": "g16"})
        qspoc.load_data_from_file(file_path=wd / "test_file/input_test_simple.csv")
        qspoc.get_init_sturct()
        qspoc.geometric_opt(method="xtb")
        qspoc.geometric_opt(method="g16", calc_command="b3lyp/def2svp", nprocs=32, memory="16GB")
        qspoc.singlepoint_energy(method="g16", calc_command="b3lyp/def2tzvp", nprocs=32, memory="16GB")
        qspoc.descriptor_calc(version="stem", cdft_command="b3lyp/def2tzvp")

    def test_with_xtb_opt_g16_sp_high(self):
        """Test basic MultiMolDesc functionality"""
        self.print_test_header("xtb opt, g16 sp, g16 cdft")

        wd = Path(__file__).parent

        qspoc = QSPOCDesc(multiwfn_path=Multiwfn_path, save_dir=wd / "test_file/test4", exe_path_dict={"xtb": "xtb", "g16": "g16"})
        qspoc.load_data_from_file(file_path=wd / "test_file/input_test_simple.csv")
        qspoc.get_init_sturct()
        qspoc.geometric_opt(method="xtb")
        qspoc.geometric_opt(method="g16", calc_command="b3lyp/def2svp", nprocs=32, memory="16GB")
        qspoc.singlepoint_energy(method="g16", calc_command="b3lyp/def2tzvp", nprocs=32, memory="16GB")
        qspoc.descriptor_calc(version="stem", cdft_command="wB97XD/def2tzvp")


if __name__ == "__main__":
    import unittest

    unittest.main(verbosity=2)
