test_process_definition.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. """Test process definition in integration."""
  18. from typing import Dict
  19. import pytest
  20. from pydolphinscheduler.core.process_definition import ProcessDefinition
  21. from pydolphinscheduler.tasks.shell import Shell
  22. PROCESS_DEFINITION_NAME = "test_change_exists_attr_pd"
  23. TASK_NAME = f"task_{PROCESS_DEFINITION_NAME}"
  24. @pytest.mark.parametrize(
  25. "pre, post",
  26. [
  27. (
  28. {
  29. "user": "pre_user",
  30. },
  31. {
  32. "user": "post_user",
  33. },
  34. )
  35. ],
  36. )
  37. def test_change_process_definition_attr(pre: Dict, post: Dict):
  38. """Test whether process definition success when specific attribute change."""
  39. assert pre.keys() == post.keys(), "Not equal keys for pre and post attribute."
  40. for attrs in [pre, post]:
  41. with ProcessDefinition(name=PROCESS_DEFINITION_NAME, **attrs) as pd:
  42. Shell(name=TASK_NAME, command="echo 1")
  43. pd.submit()