def hello_world_one_activity(self): return self.create( name='hello_world_one', tasks=runner.Sync( tasks.print_hello_task.fill( namespace='activity_one_task_one', workflow_id='execution.workflow_id', activity_name=param.StaticParam('Activity 1'), task_name=param.StaticParam('Task 1'))))
def hello_world_five_activity(self): return self.create( name='hello_world_five', tasks=runner.Async( tasks.print_hello_task.fill( namespace='activity_five_task_one', workflow_id='execution.workflow_id', sleep=param.StaticParam(10), activity_name=param.StaticParam('Activity 5'), task_name=param.StaticParam('Task 1')), tasks.print_hello_task.fill( namespace='activity_five_task_two', workflow_id='execution.workflow_id', activity_name=param.StaticParam('Activity 5'), task_name=param.StaticParam('Task 2'))))
def test_static_param(): """Test the behavior of the static param class """ message = 'Hello World' current_param = param.StaticParam(message) assert current_param.get_data({}) is message assert not list(current_param.requirements)
def test_parametrize(): """Test parametrize. Parametrize only allows objects that inherits BaseParam or string. """ keys = ['context.key1', 'context.key2', 'context.key3'] manual_keys = ['context.manual_key1', 'context.manual_key2'] params = [param.Param(key) for key in keys] params += manual_keys params += [param.StaticParam('Value')] params = [param.parametrize(current_param) for current_param in params] for current_param in params: assert isinstance(current_param, param.BaseParam) with pytest.raises(param.UnknownParamException): param.parametrize(list('Unknown'))
def test_all_requirements(): """Test getting all the requirements. """ keys = ['context.key1', 'context.key2', 'context.key3'] manual_keys = ['context.manual_key1', 'context.manual_key2'] params = [param.Param(key) for key in keys] params += manual_keys params += [param.StaticParam('Value')] params = [param.parametrize(current_param) for current_param in params] resp = param.get_all_requirements(params) for key in keys: assert key in resp for manual_key in manual_keys: assert manual_key in resp assert 'Value' not in resp