-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/add-python-toolbox-support
- Loading branch information
Showing
3 changed files
with
177 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
# exasol-error-reporting X.Y.Z, released YYYY-MM-DD | ||
# Unreleased | ||
|
||
Code Name: | ||
|
||
## Summary | ||
|
||
### Security | ||
### Bugfix | ||
### Feature | ||
### Refactoring | ||
### Documentation | ||
- #25: Add support for named parameters. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import io | ||
import pytest | ||
from inspect import cleandoc | ||
|
||
from exasol.error._parse import parse_file | ||
from exasol.error._report import ErrorCodeDetails | ||
|
||
|
||
@pytest.fixture | ||
def expected(): | ||
yield ( | ||
[ | ||
ErrorCodeDetails( | ||
identifier='E-TEST-1', | ||
message='this is an error', | ||
messagePlaceholders=[], | ||
description=None, | ||
internalDescription=None, | ||
potentialCauses=None, | ||
mitigations=['no mitigation available'], | ||
sourceFile='<StringIO>', | ||
sourceLine=6, | ||
contextHash=None), | ||
], | ||
[], | ||
[] | ||
) | ||
|
||
|
||
def test_use_only_named_parameters(expected): | ||
file = io.StringIO(initial_value=cleandoc( | ||
""" | ||
from exasol import error | ||
from exasol.error import Parameter | ||
var = input("description: ") | ||
error1 = error.ExaError( | ||
code="E-TEST-1", | ||
message="this is an error", | ||
mitigations="no mitigation available", | ||
parameters={}, | ||
) | ||
""" | ||
)) | ||
|
||
expected_defs, expected_warnings, expected_errors = expected | ||
definitions, warnings, errors = parse_file(file) | ||
|
||
assert expected_defs == definitions | ||
assert expected_warnings == warnings | ||
assert expected_errors == errors | ||
|
||
|
||
def test_dont_name_the_code_parameter(expected): | ||
file = io.StringIO(initial_value=cleandoc( | ||
""" | ||
from exasol import error | ||
from exasol.error import Parameter | ||
var = input("description: ") | ||
error1 = error.ExaError( | ||
"E-TEST-1", | ||
message="this is an error", | ||
mitigations="no mitigation available", | ||
parameters={}, | ||
) | ||
""" | ||
)) | ||
|
||
expected_defs, expected_warnings, expected_errors = expected | ||
definitions, warnings, errors = parse_file(file) | ||
|
||
assert expected_defs == definitions | ||
assert expected_warnings == warnings | ||
assert expected_errors == errors | ||
|
||
|
||
def test_dont_name_the_code_and_message_parameter(expected): | ||
file = io.StringIO(initial_value=cleandoc( | ||
""" | ||
from exasol import error | ||
from exasol.error import Parameter | ||
var = input("description: ") | ||
error1 = error.ExaError( | ||
"E-TEST-1", | ||
"this is an error", | ||
mitigations="no mitigation available", | ||
parameters={}, | ||
) | ||
""" | ||
)) | ||
|
||
expected_defs, expected_warnings, expected_errors = expected | ||
definitions, warnings, errors = parse_file(file) | ||
|
||
assert expected_defs == definitions | ||
assert expected_warnings == warnings | ||
assert expected_errors == errors | ||
|
||
|
||
def test_dont_name_the_code_message_and_mitigations_parameter(expected): | ||
file = io.StringIO(initial_value=cleandoc( | ||
""" | ||
from exasol import error | ||
from exasol.error import Parameter | ||
var = input("description: ") | ||
error1 = error.ExaError( | ||
"E-TEST-1", | ||
"this is an error", | ||
"no mitigation available", | ||
parameters={}, | ||
) | ||
""" | ||
)) | ||
|
||
expected_defs, expected_warnings, expected_errors = expected | ||
definitions, warnings, errors = parse_file(file) | ||
|
||
assert expected_defs == definitions | ||
assert expected_warnings == warnings | ||
assert expected_errors == errors | ||
|
||
|
||
def test_dont_name_any_parameter(expected): | ||
file = io.StringIO(initial_value=cleandoc( | ||
""" | ||
from exasol import error | ||
from exasol.error import Parameter | ||
var = input("description: ") | ||
error1 = error.ExaError( | ||
"E-TEST-1", | ||
"this is an error", | ||
"no mitigation available", | ||
{}, | ||
) | ||
""" | ||
)) | ||
|
||
expected_defs, expected_warnings, expected_errors = expected | ||
definitions, warnings, errors = parse_file(file) | ||
|
||
assert expected_defs == definitions | ||
assert expected_warnings == warnings | ||
assert expected_errors == errors |