"""Test Jinja templates module.""" from glicid_spawner.templates import get_template_src, render_template def test_template_src(): """Test jinja template source.""" src = get_template_src('slurm_script.jinja') assert src.startswith('#!/bin/bash\n{#- SLURM batch script for GLiCID spawner #}') assert src.endswith('} > ${JUPYTER_JOB_LOG} 2>&1\n') def test_template_render(): """Test jinja template render.""" src = render_template('slurm_script.jinja', job_name='foo', qos='short', gres='bar', cmd='cmd') assert src.startswith('#!/bin/bash\n\n#SBATCH --job-name=foo\n') assert '#SBATCH --export=\n#SBATCH --qos=short\n#SBATCH --gres=bar\n' in src assert src.endswith('cmd;} > ${JUPYTER_JOB_LOG} 2>&1')