def test_set_attr_return_special_object(set_attr, set_val, get_attr, get_val): """Test process definition set attributes which get with different type.""" with ProcessDefinition(TEST_PROCESS_DEFINITION_NAME) as pd: setattr(pd, set_attr, set_val) assert get_val == getattr( pd, get_attr ), f"Set attribute {set_attr} can not get back with {get_val}."
def test__parse_datetime(val, expect): """Test process definition function _parse_datetime. Only two datetime test cases here because we have more test cases in tests/utils/test_date.py file. """ with ProcessDefinition(TEST_PROCESS_DEFINITION_NAME) as pd: assert expect == pd._parse_datetime( val), f"Function _parse_datetime with unexpect value by {val}."
def test_sub_process_to_dict(mock_process_definition): """Test task sub_process function to_dict.""" code = 123 version = 1 name = "test_sub_process_to_dict" expect = { "code": code, "name": name, "version": 1, "description": None, "delayTime": 0, "taskType": "SUB_PROCESS", "taskParams": { "resourceList": [], "localParams": [], "processDefinitionCode": TEST_SUB_PROCESS_DEFINITION_CODE, "dependence": {}, "conditionResult": { "successNode": [""], "failedNode": [""] }, "waitStartTimeout": {}, }, "flag": "YES", "taskPriority": "MEDIUM", "workerGroup": "default", "failRetryTimes": 0, "failRetryInterval": 1, "timeoutFlag": "CLOSE", "timeoutNotifyStrategy": None, "timeout": 0, } with patch( "pydolphinscheduler.core.task.Task.gen_code_and_version", return_value=(code, version), ): with ProcessDefinition(TEST_PROCESS_DEFINITION_NAME): sub_process = SubProcess(name, TEST_SUB_PROCESS_DEFINITION_NAME) assert sub_process.to_dict() == expect
def test__parse_datetime_not_support_type(val: Any): """Test process definition function _parse_datetime not support type error.""" with ProcessDefinition(TEST_PROCESS_DEFINITION_NAME) as pd: with pytest.raises(PyDSParamException, match="Do not support value type.*?"): pd._parse_datetime(val)
def test__parse_datetime_not_support_type(val: Any): """Test process definition function _parse_datetime not support type error.""" with ProcessDefinition(TEST_PROCESS_DEFINITION_NAME) as pd: with pytest.raises(ValueError): pd._parse_datetime(val)