# Path: tests/utils.py
# def run_temci(args: str, settings: dict = None, files: Dict[str, Union[dict, list, str]] = None,
#               expect_success: bool = True, misc_env: Dict[str, str] = None, raise_exc: bool = False) \
#         -> Result:
#     """
#     Run temci with the passed arguments
# 
#     :param args: arguments for temci
#     :param settings: settings dictionary, stored in a file called `settings.yaml` and appended to the arguments
#     :param files: {file name: content as string or dictionary that is converted into YAML first}
#     :param expect_success: expect a zero return code
#     :param misc_env: additional environment variables
#     :return: result of the call
#     """
#     if os.getenv("TEMCI_TEST_CMD", "0") == "1":
#         return run_temci_proc(args, settings, files, expect_success, misc_env=misc_env)
#     return run_temci_click(args, settings, files, expect_success, misc_env=misc_env, raise_exc=raise_exc)


from tests.utils import run_temci
"""
Basic command line tool tests
"""


def test_max_runs_per_block():
    assert " 1 single bench" in run_temci("exec bla.yaml", settings={
            "run": {
                "max_runs": 4,
                "min_runs": 2
            }
        },
        files={"bla.yaml": [{
          "run_config":
              {
                  "cmd": "ls",
                  "max_runs": 1
              }
          }, {
          "run_config":
              {
                  "cmd": "ls .",
                  "max_runs": 3
              }
          }]}).out


def test_config_default_values():

# Path: tests/utils.py
# def run_temci(args: str, settings: dict = None, files: Dict[str, Union[dict, list, str]] = None,
#               expect_success: bool = True, misc_env: Dict[str, str] = None, raise_exc: bool = False) \
#         -> Result:
#     """
#     Run temci with the passed arguments
# 
#     :param args: arguments for temci
#     :param settings: settings dictionary, stored in a file called `settings.yaml` and appended to the arguments
#     :param files: {file name: content as string or dictionary that is converted into YAML first}
#     :param expect_success: expect a zero return code
#     :param misc_env: additional environment variables
#     :return: result of the call
#     """
#     if os.getenv("TEMCI_TEST_CMD", "0") == "1":
#         return run_temci_proc(args, settings, files, expect_success, misc_env=misc_env)
#     return run_temci_click(args, settings, files, expect_success, misc_env=misc_env, raise_exc=raise_exc)


# Path: tests/test_basic.py
from tests.utils import run_temci

"""
Basic command line tool tests
"""


def test_max_runs_per_block():
    assert " 1 single bench" in run_temci("exec bla.yaml", settings={
            "run": {
                "max_runs": 4,
                "min_runs": 2
            }
        },
        files={"bla.yaml": [{
          "run_config":
              {
                  "cmd": "ls",
                  "max_runs": 1
              }
          }, {
          "run_config":
              {
                  "cmd": "ls .",
                  "max_runs": 3
              }
          }]}).out


def test_config_default_values():

    assert "11 single bench" in run_temci("short exec ls --log_level debug", settings={