Browse Source

[python] Fix process definition's user assigned not pass (#6753)

3.0.0/version-upgrade
Jiajie Zhong 3 years ago committed by GitHub
parent
commit
cd8205217a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/core/process_definition.py
  2. 28
      dolphinscheduler-python/pydolphinscheduler/tests/core/test_process_definition.py

4
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/core/process_definition.py

@ -144,8 +144,8 @@ class ProcessDefinition(Base):
ProcessDefinitionDefault.USER_PWD,
ProcessDefinitionDefault.USER_EMAIL,
ProcessDefinitionDefault.USER_PHONE,
ProcessDefinitionDefault.TENANT,
ProcessDefinitionDefault.QUEUE,
self._tenant,
self._queue,
ProcessDefinitionDefault.USER_STATE,
)

28
dolphinscheduler-python/pydolphinscheduler/tests/core/test_process_definition.py

@ -145,3 +145,31 @@ def test_process_definition_simple():
assert task._downstream_task_codes == {
pd.get_one_task_by_name(f"task-{i + 1}").code
}
@pytest.mark.parametrize(
"user_attrs",
[
{"tenant": "tenant_specific"},
{"queue": "queue_specific"},
{"tenant": "tenant_specific", "queue": "queue_specific"},
],
)
def test_set_process_definition_user_attr(user_attrs):
"""Test user with correct attributes if we specific assigned to process definition object."""
default_value = {
"tenant": ProcessDefinitionDefault.TENANT,
"queue": ProcessDefinitionDefault.QUEUE,
}
with ProcessDefinition(TEST_PROCESS_DEFINITION_NAME, **user_attrs) as pd:
user = pd.user
for attr in default_value:
# Get assigned attribute if we specific, else get default value
except_attr = (
user_attrs[attr] if attr in user_attrs else default_value[attr]
)
# Get actually attribute of user object
actual_attr = getattr(user, attr)
assert (
except_attr == actual_attr
), f"Except attribute is {except_attr} but get {actual_attr}"

Loading…
Cancel
Save