"""
Error-path tests for the 'init' command (e4s_cl/cli/commands/init.py).

These tests exercise argument-validation failures that occur before any MPI
execution or tracing takes place.  They are therefore portable and require no
MPI installation or running container daemon.
"""

import tests
from e4s_cl.model.profile import Profile
from e4s_cl.cli.commands.init import COMMAND


class InitArgumentErrorTest(tests.TestCase):
    """Argument validation errors in InitCommand.main()."""

    def tearDown(self):
        Profile.controller().unselect()
        self.resetStorage()

    def test_bad_launcher_fails(self):
        """--launcher with a binary not on PATH must fail at argument parsing time."""
        self.assertNotCommandReturnValue(
            0, COMMAND, ['--launcher', 'no_such_launcher_4e2scl_test'])

    def test_bad_launcher_with_extra_options_fails(self):
        """Combining a bad --launcher with other valid options still fails."""
        self.assertNotCommandReturnValue(
            0, COMMAND,
            ['--launcher', 'no_such_launcher_4e2scl_test',
             '--launcher_args', '-n 2',
             '--profile', 'my_profile'])
