Esempio n. 1
0
def test_check_integrity_warning() -> None:
    m = Mod(foo = -10)
    issues = ValidationIssues(
        error=[],
        warning=[ValidationIssue(9999, "EXT:W", "Custom extension reports warning", "wrn")],
    )
    assert v.check_integrity([m]) == issues
Esempio n. 2
0
def test_check_integrity_error() -> None:
    m = Mod(foo = 10)
    issues = ValidationIssues(
        error=[ValidationIssue(9999, "EXT:E", "Custom extension reports error", "err")],
        warning=[],
    )
    assert v.check_integrity([m]) == issues
Esempio n. 3
0
def test_process_validation_issues_error(mock_warn: MagicMock, mock_error: MagicMock) -> None:
    issues = ValidationIssues(
        error=[],
        warning=[ValidationIssue(9999, "EXT:W", "Custom extension reports warning", "wrn")],
    )
    v.process_validation_issues(issues)
    assert not mock_error.called
    assert mock_warn.called
Esempio n. 4
0
def test_warning_decorator_custom() -> None:
    @v.warning("W1")
    def good():
        return None
    assert good() == []

    @v.warning("W2")
    def bad():
        return "bad"
    assert bad() == [ValidationIssue(9999, "EXT:W2", "Custom extension reports warning", "bad")]
Esempio n. 5
0
def test_error_decorator_custom() -> None:
    @v.error("E1")
    def good():
        return None
    assert good() == []

    @v.error("E2")
    def bad():
        return "bad"
    assert bad() == [ValidationIssue(9999, "EXT:E2", "Custom extension reports error", "bad")]
Esempio n. 6
0
def test_warning_decorator_code() -> None:
    for warning in Warning.all():
        @v.warning(warning)
        def good():
            return None
        assert good() == []

        @v.warning(warning)
        def bad():
            return "bad"
        assert bad() == [ValidationIssue(warning.code, warning.name, warning.description, "bad")]
Esempio n. 7
0
def test_error_decorator_code() -> None:
    for error in Error.all():
        @v.error(error)
        def good():
            return None
        assert good() == []

        @v.error(error)
        def bad():
            return "bad"
        assert bad() == [ValidationIssue(error.code, error.name, error.description, "bad")]