Skip to content

Commit

Permalink
add test for non-renderable env
Browse files Browse the repository at this point in the history
  • Loading branch information
goFrendiAsgard committed Nov 29, 2023
1 parent 08cbb44 commit f0b7c39
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
22 changes: 0 additions & 22 deletions test/task/test_task.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from zrb.task.task import Task
from zrb.task.cmd_task import CmdTask
from zrb.task_input.str_input import StrInput
import asyncio

Expand Down Expand Up @@ -103,24 +102,3 @@ def test_callable_as_task_should_execute_value():
function = task.to_function()
result = function()
assert result == 'articuno'


def test_consistent_execution_id():
task_upstream_1 = Task(
name='task-upstream-1',
run=lambda *args, **kwargs: kwargs.get('_task').get_execution_id()
)
task_upstream_2 = CmdTask(
name='task-upstream-2',
cmd='echo $_ZRB_EXECUTION_ID'
)
task = Task(
name='task',
upstreams=[
task_upstream_1, task_upstream_2
],
return_upstream_result=True
)
function = task.to_function()
result = function()
assert result[0] == result[1].output
27 changes: 27 additions & 0 deletions test/task/test_task_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ def _run(*args, **kwargs) -> str:
assert result == 'Elixir of immortality'


def test_task_env_with_should_not_be_rendered_jinja_value():
def _run(*args, **kwargs) -> str:
task: Task = kwargs.get('_task')
env_map = task.get_env_map()
return env_map.get('ZRB_TEST_TASK_ENV_2')
task = Task(
name='templated-env',
envs=[
Env(name='ZRB_TEST_TASK_ENV_1', default='Elixir'),
Env(
name='ZRB_TEST_TASK_ENV_2',
default='{{env.ZRB_TEST_TASK_ENV_1}} of immortality',
should_render=False
)
],
run=_run,
retry=0
)
function = task.to_function()
if 'ZRB_TEST_TASK_ENV_1' in os.environ:
del os.environ['ZRB_TEST_TASK_ENV_1']
if 'ZRB_TEST_TASK_ENV_2' in os.environ:
del os.environ['ZRB_TEST_TASK_ENV_2']
result = function()
assert result == '{{env.ZRB_TEST_TASK_ENV_1}} of immortality'


def test_task_env_with_none_as_os_name():
'''
When env exist, it should override env_file
Expand Down

0 comments on commit f0b7c39

Please sign in to comment.