Skip to content

Commit

Permalink
Add tests for CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Schilling Christian (XC-AD/ETV5) authored and clellmann committed Aug 29, 2022
1 parent a8cbb41 commit ae5d753
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/cli/commands/test_dag_command.py
Expand Up @@ -17,6 +17,7 @@
# under the License.
import contextlib
import io
import json
import os
import tempfile
import unittest
Expand Down Expand Up @@ -607,6 +608,40 @@ def test_dag_test(self, mock_get_dag, mock_executor):
executor=mock_executor.return_value,
start_date=cli_args.execution_date,
end_date=cli_args.execution_date,
conf=None,
run_at_least_once=True,
),
]
)

@mock.patch("airflow.cli.commands.dag_command.DebugExecutor")
@mock.patch("airflow.cli.commands.dag_command.get_dag")
def test_dag_test_conf(self, mock_get_dag, mock_executor):
cli_args = self.parser.parse_args(
[
'dags',
'test',
'example_bash_operator',
DEFAULT_DATE.isoformat(),
"-c",
"{\"dag_run_conf_param\": \"param_value\"}",
]
)
dag_command.dag_test(cli_args)

mock_get_dag.assert_has_calls(
[
mock.call(subdir=cli_args.subdir, dag_id='example_bash_operator'),
mock.call().clear(
start_date=cli_args.execution_date,
end_date=cli_args.execution_date,
dag_run_state=False,
),
mock.call().run(
executor=mock_executor.return_value,
start_date=cli_args.execution_date,
end_date=cli_args.execution_date,
conf=json.loads(cli_args.conf),
run_at_least_once=True,
),
]
Expand Down Expand Up @@ -636,6 +671,7 @@ def test_dag_test_show_dag(self, mock_get_dag, mock_executor, mock_render_dag):
executor=mock_executor.return_value,
start_date=cli_args.execution_date,
end_date=cli_args.execution_date,
conf=None,
run_at_least_once=True,
),
]
Expand Down

0 comments on commit ae5d753

Please sign in to comment.