예제 #1
0
 def test_cli_test_with_params(self):
     task_command.task_test(self.parser.parse_args([
         'tasks', 'test', 'example_passing_params_via_test_command', 'run_this',
         '--task-params', '{"foo":"bar"}', DEFAULT_DATE.isoformat()]))
     task_command.task_test(self.parser.parse_args([
         'tasks', 'test', 'example_passing_params_via_test_command', 'also_run_this',
         '--task-params', '{"foo":"bar"}', DEFAULT_DATE.isoformat()]))
예제 #2
0
 def test_cli_test(self):
     task_command.task_test(self.parser.parse_args([
         'tasks', 'test', 'example_bash_operator', 'runme_0',
         DEFAULT_DATE.isoformat()]))
     task_command.task_test(self.parser.parse_args([
         'tasks', 'test', 'example_bash_operator', 'runme_0', '--dry-run',
         DEFAULT_DATE.isoformat()]))
예제 #3
0
 def test_cli_test_with_env_vars(self):
     with redirect_stdout(io.StringIO()) as stdout:
         task_command.task_test(self.parser.parse_args([
             'tasks', 'test', 'example_passing_params_via_test_command', 'env_var_test_task',
             '--env-vars', '{"foo":"bar"}', DEFAULT_DATE.isoformat()]))
     output = stdout.getvalue()
     self.assertIn('foo=bar', output)
     self.assertIn('AIRFLOW_TEST_MODE=True', output)
예제 #4
0
    def test_test(self):
        """Test the `airflow test` command"""
        args = self.parser.parse_args([
            "tasks", "test", "example_python_operator", 'print_the_context', '2018-01-01'
        ])

        with redirect_stdout(io.StringIO()) as stdout:
            task_command.task_test(args)
        # Check that prints, and log messages, are shown
        self.assertIn("'example_python_operator__print_the_context__20180101'", stdout.getvalue())
예제 #5
0
    def test_test(self):
        """Test the `airflow test` command"""
        args = create_mock_args(task_id='print_the_context',
                                dag_id='example_python_operator',
                                subdir=None,
                                execution_date=timezone.parse('2018-01-01'))

        with redirect_stdout(io.StringIO()) as stdout:
            task_command.task_test(args)
        # Check that prints, and log messages, are shown
        self.assertIn("'example_python_operator__print_the_context__20180101'",
                      stdout.getvalue())
예제 #6
0
    def test_test(self, mock_run_mini_scheduler):
        """Test the `airflow test` command"""
        args = self.parser.parse_args([
            "tasks", "test", "example_python_operator", 'print_the_context',
            '2018-01-01'
        ])

        with redirect_stdout(io.StringIO()) as stdout:
            task_command.task_test(args)

        mock_run_mini_scheduler.assert_not_called()
        # Check that prints, and log messages, are shown
        assert "'example_python_operator__print_the_context__20180101'" in stdout.getvalue(
        )
    def test_test(self):
        """Test the `airflow test` command"""
        args = create_mock_args(task_id='print_the_context',
                                dag_id='example_python_operator',
                                subdir=None,
                                execution_date=timezone.parse('2018-01-01'))

        saved_stdout = sys.stdout
        try:
            sys.stdout = out = io.StringIO()
            task_command.task_test(args)

            output = out.getvalue()
            # Check that prints, and log messages, are shown
            self.assertIn(
                "'example_python_operator__print_the_context__20180101'",
                output)
        finally:
            sys.stdout = saved_stdout