# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with lava-tool.  If not, see <http://www.gnu.org/licenses/>.
"""Test definition templates."""

from lava.parameter import (
    Parameter, )

DEFAULT_TESTDEF_VERSION = "1.0"
DEFAULT_TESTDEF_FORMAT = "Lava-Test Test Definition 1.0"
DEFAULT_ENVIRONMET_VALUE = "lava_test_shell"

# All these parameters will not be stored on the local config file.
NAME_PARAMETER = Parameter("name")
NAME_PARAMETER.store = False

DESCRIPTION_PARAMETER = Parameter("description", depends=NAME_PARAMETER)
DESCRIPTION_PARAMETER.store = False

TESTDEF_STEPS_KEY = "steps"

TESTDEF_TEMPLATE = {
    "metadata": {
        "name": NAME_PARAMETER,
        "format": DEFAULT_TESTDEF_FORMAT,
        "version": DEFAULT_TESTDEF_VERSION,
        "description": DESCRIPTION_PARAMETER,
        "environment": [DEFAULT_ENVIRONMET_VALUE],
    },
    "run": {
    base64_encode,
    create_dir,
    create_tar,
    edit_file,
    retrieve_file,
    write_file,
)

# Default directory structure name.
TESTS_DIR = "tests"

# Internal parameter ids.
JOBFILE_ID = "jobfile"

JOBFILE_PARAMETER = Parameter(JOBFILE_ID)
JOBFILE_PARAMETER.store = False

INIT_TEMPLATE = {
    JOBFILE_ID: JOBFILE_PARAMETER,
}


class init(BaseCommand):
    """Set-ups the base directory structure."""
    @classmethod
    def register_arguments(cls, parser):
        super(init, cls).register_arguments(parser)
        parser.add_argument("DIR",
                            help=("The name of the directory to initialize. "
                                  "Defaults to current working directory."),
                            nargs="?",