コード例 #1
0
ファイル: test_base.py プロジェクト: MasterHM-ml/prefect
    def test_result_validate_calls_validate_functions_from_attribute(self):
        _example_function = MagicMock(return_value=True)

        r = Result(value=None, validators=[_example_function])
        r.validate()

        _example_function.assert_called_once_with(r)
コード例 #2
0
ファイル: test_base.py プロジェクト: MasterHM-ml/prefect
    def test_result_validate_raises_exceptions(self):
        def _example_function(result):
            raise TypeError

        r = Result(value=None, validators=[_example_function])
        with pytest.raises(TypeError):
            r.validate()
コード例 #3
0
ファイル: test_base.py プロジェクト: MasterHM-ml/prefect
    def test_result_validate_returns_true_on_none_invalid(self):
        no_false_validators_fns = [lambda r: True, lambda r: True]

        r = Result(value=None, validators=no_false_validators_fns)
        is_valid = r.validate()

        assert is_valid is True
コード例 #4
0
ファイル: test_base.py プロジェクト: MasterHM-ml/prefect
    def test_result_validate_returns_false_on_any_invalid(self):
        one_false_validators_fns = [lambda r: True, lambda r: False]

        r = Result(value=None, validators=one_false_validators_fns)
        is_valid = r.validate()

        assert is_valid is False
コード例 #5
0
ファイル: test_base.py プロジェクト: MasterHM-ml/prefect
    def test_result_validate_warns_when_run_without_run_validators_flag(
            self, caplog):
        _example_function = MagicMock(return_value=True)

        r = Result(value=None,
                   validators=[_example_function],
                   run_validators=False)
        with caplog.at_level(logging.WARNING, "prefect.Result"):
            is_valid = r.validate()

        # it should have acted normal and called the validate functions
        _example_function.assert_called_once_with(r)
        assert is_valid is True

        # but ALSO it should published a warning log, going on about run_validators not being set
        assert caplog.text.find("WARNING") > -1
        assert caplog.text.find("run_validators") > -1