def test_should_display_value(self):
        with contextlib.redirect_stdout(io.StringIO()) as temp_stdout:
            config_command.get_value(
                self.parser.parse_args(
                    ['config', 'get-value', 'core', 'test_key']))

        self.assertEqual("test_value", temp_stdout.getvalue().strip())
Пример #2
0
    def test_should_raise_exception_when_option_is_missing(self, mock_conf):
        mock_conf.has_section.return_value = True
        mock_conf.has_option.return_value = False

        with pytest.raises(SystemExit) as ctx:
            config_command.get_value(
                self.parser.parse_args(['config', 'get-value', 'missing-section', 'dags_folder'])
            )
        assert "The option [missing-section/dags_folder] is not found in config." == str(ctx.value)
Пример #3
0
    def test_should_display_value(self):
        with pytest.raises(SystemExit) as ctx, contextlib.redirect_stderr(io.StringIO()) as temp_stderr:
            config_command.get_value(self.parser.parse_args(['worker']))

        assert 2 == ctx.value.code
        assert (
            "`airflow worker` command, has been removed, "
            "please use `airflow celery worker`, see help above." in temp_stderr.getvalue().strip()
        )
Пример #4
0
    def test_should_display_value(self):
        with self.assertRaises(SystemExit) as cm_exception, \
                contextlib.redirect_stderr(io.StringIO()) as temp_stderr:
            config_command.get_value(self.parser.parse_args(['worker']))

        self.assertEqual(2, cm_exception.exception.code)
        self.assertIn(
            "`airflow worker` command, has been removed, "
            "please use `airflow celery worker`, see help above.",
            temp_stderr.getvalue().strip())
    def test_should_raise_exception_when_option_is_missing(self, mock_conf):
        mock_conf.has_section.return_value = True
        mock_conf.has_option.return_value = False

        with self.assertRaises(SystemExit) as err:
            config_command.get_value(
                self.parser.parse_args(
                    ['config', 'get-value', 'missing-section', 'dags_folder']))
        self.assertEqual(
            "The option [missing-section/dags_folder] is not found in config.",
            str(err.exception))
Пример #6
0
    def test_should_raise_exception_when_option_is_missing(self, mock_conf):
        mock_conf.has_section.return_value = True
        mock_conf.has_option.return_value = False

        with contextlib.redirect_stderr(
                io.StringIO()) as temp_stderr, self.assertRaises(
                    SystemExit) as cm:
            config_command.get_value(
                self.parser.parse_args(
                    ['config', 'get-value', 'missing-section', 'dags_folder']))
        self.assertEqual(1, cm.exception.code)
        self.assertEqual(
            "The option [missing-section/dags_folder] is not found in config.",
            temp_stderr.getvalue().strip())