Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/changes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
## Internal

* #68 Update to poetry 2.1.2 and exasol-toolbox 1.1.0
* Update transitive dependencies
* Update transitive dependencies
* #67 Extend unit test to contain test scenarios with different values for the parameter description
3 changes: 2 additions & 1 deletion exasol/error/_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,11 @@ def _validate_parameter_values(self, parameter_node: ast.Dict, file: str) -> boo
Checks if value of ast dictionary are of expected type.
If the values are of expected type, the method returns True, otherwise False.
"""

ret_val = True
for value in parameter_node.values:
if isinstance(value, ast.Call):
if len(value.args) < 2:
value.args.append(ast.Constant(value=None))
description = value.args[1]
if not self._check_node_type(
ast.Constant, description, "description", file
Expand Down
252 changes: 252 additions & 0 deletions test/unit/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,96 @@
)
],
),
(
cleandoc(
"""
from exasol import error

error1 = error.ExaError(
"E-TEST-1",
"this is an error",
["no mitigation available"],
{"param": error.Parameter("value", "")},
)
"""
),
[
ErrorCodeDetails(
identifier="E-TEST-1",
message="this is an error",
messagePlaceholders=[
Placeholder(placeholder="param", description="")
],
description=None,
internalDescription=None,
potentialCauses=None,
mitigations=["no mitigation available"],
sourceFile="<Unknown>",
sourceLine=3,
contextHash=None,
)
],
),
(
cleandoc(
"""
from exasol import error

error1 = error.ExaError(
"E-TEST-1",
"this is an error",
["no mitigation available"],
{"param": error.Parameter("value", None)},
)
"""
),
[
ErrorCodeDetails(
identifier="E-TEST-1",
message="this is an error",
messagePlaceholders=[
Placeholder(placeholder="param", description="")
],
description=None,
internalDescription=None,
potentialCauses=None,
mitigations=["no mitigation available"],
sourceFile="<Unknown>",
sourceLine=3,
contextHash=None,
)
],
),
(
cleandoc(
"""
from exasol import error

error1 = error.ExaError(
"E-TEST-1",
"this is an error",
["no mitigation available"],
{"param": error.Parameter("value")},
)
"""
),
[
ErrorCodeDetails(
identifier="E-TEST-1",
message="this is an error",
messagePlaceholders=[
Placeholder(placeholder="param", description="")
],
description=None,
internalDescription=None,
potentialCauses=None,
mitigations=["no mitigation available"],
sourceFile="<Unknown>",
sourceLine=3,
contextHash=None,
)
],
),
],
)
def test_ErrorCollector_error_definitions(src, expected):
Expand Down Expand Up @@ -211,6 +301,96 @@ def test_ErrorCollector_error_definitions(src, expected):
)
],
),
(
cleandoc(
"""
from exasol import error
from exasol.error import Parameter

var = input("description: ")

error1 = error.ExaError(
"E-TEST-1",
var,
["mitigations"],
{"param": Parameter("value", "")},
)
"""
),
[
Error(
code=INVALID_ERROR_CODE_DEFINITION.identifier,
message=INVALID_ERROR_CODE_DEFINITION.message,
mitigations=INVALID_ERROR_CODE_DEFINITION.mitigations,
parameters={
"error_element": "message",
"file": "<Unknown>",
"line": "8",
"defined_type": f"<class '{AST_NAME_CLASS}'>",
},
)
],
),
(
cleandoc(
"""
from exasol import error
from exasol.error import Parameter

var = input("description: ")

error1 = error.ExaError(
"E-TEST-1",
var,
["mitigations"],
{"param": Parameter("value", None)},
)
"""
),
[
Error(
code=INVALID_ERROR_CODE_DEFINITION.identifier,
message=INVALID_ERROR_CODE_DEFINITION.message,
mitigations=INVALID_ERROR_CODE_DEFINITION.mitigations,
parameters={
"error_element": "message",
"file": "<Unknown>",
"line": "8",
"defined_type": f"<class '{AST_NAME_CLASS}'>",
},
)
],
),
(
cleandoc(
"""
from exasol import error
from exasol.error import Parameter

var = input("description: ")

error1 = error.ExaError(
"E-TEST-1",
var,
["mitigations"],
{"param": Parameter("value")},
)
"""
),
[
Error(
code=INVALID_ERROR_CODE_DEFINITION.identifier,
message=INVALID_ERROR_CODE_DEFINITION.message,
mitigations=INVALID_ERROR_CODE_DEFINITION.mitigations,
parameters={
"error_element": "message",
"file": "<Unknown>",
"line": "8",
"defined_type": f"<class '{AST_NAME_CLASS}'>",
},
)
],
),
],
)
def test_ErrorCollector_errors(src, expected):
Expand Down Expand Up @@ -256,6 +436,78 @@ def test_ErrorCollector_errors(src, expected):
),
[],
),
(
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"],
{"param": Parameter("value", "description")},
)
"""
),
[],
),
(
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"],
{"param": Parameter("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"],
{"param": Parameter("value", None)},
)
"""
),
[],
),
(
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"],
{"param": Parameter("value")},
)
"""
),
[],
),
],
)
def test_ErrorCollector_warnings(src, expected):
Expand Down