Skip to content

Commit dafd6f4

Browse files
committed
extend unit test #67
1 parent 03aa422 commit dafd6f4

3 files changed

Lines changed: 257 additions & 2 deletions

File tree

doc/changes/unreleased.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
## Internal
44

55
* #68 Update to poetry 2.1.2 and exasol-toolbox 1.1.0
6-
* Update transitive dependencies
6+
* Update transitive dependencies
7+
* #67 Extend unit test to contain test scenarios with different values of description

exasol/error/_parse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,11 @@ def _validate_parameter_values(self, parameter_node: ast.Dict, file: str) -> boo
307307
Checks if value of ast dictionary are of expected type.
308308
If the values are of expected type, the method returns True, otherwise False.
309309
"""
310-
311310
ret_val = True
312311
for value in parameter_node.values:
313312
if isinstance(value, ast.Call):
313+
if len(value.args) < 2:
314+
value.args.append(ast.Constant(value=None))
314315
description = value.args[1]
315316
if not self._check_node_type(
316317
ast.Constant, description, "description", file

test/unit/cli_test.py

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,97 @@
4949
)
5050
],
5151
),
52+
(
53+
cleandoc(
54+
"""
55+
from exasol import error
56+
57+
error1 = error.ExaError(
58+
"E-TEST-1",
59+
"this is an error",
60+
["no mitigation available"],
61+
{"param": error.Parameter("value", "")},
62+
)
63+
"""
64+
),
65+
[
66+
ErrorCodeDetails(
67+
identifier="E-TEST-1",
68+
message="this is an error",
69+
messagePlaceholders=[
70+
Placeholder(placeholder="param", description="")
71+
],
72+
description=None,
73+
internalDescription=None,
74+
potentialCauses=None,
75+
mitigations=["no mitigation available"],
76+
sourceFile="<Unknown>",
77+
sourceLine=3,
78+
contextHash=None,
79+
)
80+
],
81+
),
82+
(
83+
cleandoc(
84+
"""
85+
from exasol import error
86+
87+
error1 = error.ExaError(
88+
"E-TEST-1",
89+
"this is an error",
90+
["no mitigation available"],
91+
{"param": error.Parameter("value", None)},
92+
)
93+
"""
94+
),
95+
[
96+
ErrorCodeDetails(
97+
identifier="E-TEST-1",
98+
message="this is an error",
99+
messagePlaceholders=[
100+
Placeholder(placeholder="param", description="")
101+
],
102+
description=None,
103+
internalDescription=None,
104+
potentialCauses=None,
105+
mitigations=["no mitigation available"],
106+
sourceFile="<Unknown>",
107+
sourceLine=3,
108+
contextHash=None,
109+
)
110+
],
111+
),
112+
(
113+
cleandoc(
114+
"""
115+
from exasol import error
116+
117+
error1 = error.ExaError(
118+
"E-TEST-1",
119+
"this is an error",
120+
["no mitigation available"],
121+
{"param": error.Parameter("value")},
122+
)
123+
"""
124+
),
125+
[
126+
ErrorCodeDetails(
127+
identifier="E-TEST-1",
128+
message="this is an error",
129+
messagePlaceholders=[
130+
Placeholder(placeholder="param", description="")
131+
],
132+
description=None,
133+
internalDescription=None,
134+
potentialCauses=None,
135+
mitigations=["no mitigation available"],
136+
sourceFile="<Unknown>",
137+
sourceLine=3,
138+
contextHash=None,
139+
)
140+
],
141+
),
142+
52143
],
53144
)
54145
def test_ErrorCollector_error_definitions(src, expected):
@@ -211,6 +302,96 @@ def test_ErrorCollector_error_definitions(src, expected):
211302
)
212303
],
213304
),
305+
(
306+
cleandoc(
307+
"""
308+
from exasol import error
309+
from exasol.error import Parameter
310+
311+
var = input("description: ")
312+
313+
error1 = error.ExaError(
314+
"E-TEST-1",
315+
var,
316+
["mitigations"],
317+
{"param": Parameter("value", "")},
318+
)
319+
"""
320+
),
321+
[
322+
Error(
323+
code=INVALID_ERROR_CODE_DEFINITION.identifier,
324+
message=INVALID_ERROR_CODE_DEFINITION.message,
325+
mitigations=INVALID_ERROR_CODE_DEFINITION.mitigations,
326+
parameters={
327+
"error_element": "message",
328+
"file": "<Unknown>",
329+
"line": "8",
330+
"defined_type": f"<class '{AST_NAME_CLASS}'>",
331+
},
332+
)
333+
],
334+
),
335+
(
336+
cleandoc(
337+
"""
338+
from exasol import error
339+
from exasol.error import Parameter
340+
341+
var = input("description: ")
342+
343+
error1 = error.ExaError(
344+
"E-TEST-1",
345+
var,
346+
["mitigations"],
347+
{"param": Parameter("value", None)},
348+
)
349+
"""
350+
),
351+
[
352+
Error(
353+
code=INVALID_ERROR_CODE_DEFINITION.identifier,
354+
message=INVALID_ERROR_CODE_DEFINITION.message,
355+
mitigations=INVALID_ERROR_CODE_DEFINITION.mitigations,
356+
parameters={
357+
"error_element": "message",
358+
"file": "<Unknown>",
359+
"line": "8",
360+
"defined_type": f"<class '{AST_NAME_CLASS}'>",
361+
},
362+
)
363+
],
364+
),
365+
(
366+
cleandoc(
367+
"""
368+
from exasol import error
369+
from exasol.error import Parameter
370+
371+
var = input("description: ")
372+
373+
error1 = error.ExaError(
374+
"E-TEST-1",
375+
var,
376+
["mitigations"],
377+
{"param": Parameter("value")},
378+
)
379+
"""
380+
),
381+
[
382+
Error(
383+
code=INVALID_ERROR_CODE_DEFINITION.identifier,
384+
message=INVALID_ERROR_CODE_DEFINITION.message,
385+
mitigations=INVALID_ERROR_CODE_DEFINITION.mitigations,
386+
parameters={
387+
"error_element": "message",
388+
"file": "<Unknown>",
389+
"line": "8",
390+
"defined_type": f"<class '{AST_NAME_CLASS}'>",
391+
},
392+
)
393+
],
394+
),
214395
],
215396
)
216397
def test_ErrorCollector_errors(src, expected):
@@ -256,6 +437,78 @@ def test_ErrorCollector_errors(src, expected):
256437
),
257438
[],
258439
),
440+
(
441+
cleandoc(
442+
"""
443+
from exasol import error
444+
from exasol.error import Parameter
445+
446+
var = input("description: ")
447+
448+
error1 = error.ExaError(
449+
"E-TEST-1",
450+
"this is an error",
451+
["no mitigation available"],
452+
{"param": Parameter("value", "description")},
453+
)
454+
"""
455+
),
456+
[],
457+
),
458+
(
459+
cleandoc(
460+
"""
461+
from exasol import error
462+
from exasol.error import Parameter
463+
464+
var = input("description: ")
465+
466+
error1 = error.ExaError(
467+
"E-TEST-1",
468+
"this is an error",
469+
["no mitigation available"],
470+
{"param": Parameter("value", "")},
471+
)
472+
"""
473+
),
474+
[],
475+
),
476+
(
477+
cleandoc(
478+
"""
479+
from exasol import error
480+
from exasol.error import Parameter
481+
482+
var = input("description: ")
483+
484+
error1 = error.ExaError(
485+
"E-TEST-1",
486+
"this is an error",
487+
["no mitigation available"],
488+
{"param": Parameter("value", None)},
489+
)
490+
"""
491+
),
492+
[],
493+
),
494+
(
495+
cleandoc(
496+
"""
497+
from exasol import error
498+
from exasol.error import Parameter
499+
500+
var = input("description: ")
501+
502+
error1 = error.ExaError(
503+
"E-TEST-1",
504+
"this is an error",
505+
["no mitigation available"],
506+
{"param": Parameter("value")},
507+
)
508+
"""
509+
),
510+
[],
511+
),
259512
],
260513
)
261514
def test_ErrorCollector_warnings(src, expected):

0 commit comments

Comments
 (0)