|
49 | 49 | ) |
50 | 50 | ], |
51 | 51 | ), |
| 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 | + ), |
52 | 142 | ], |
53 | 143 | ) |
54 | 144 | def test_ErrorCollector_error_definitions(src, expected): |
@@ -211,6 +301,96 @@ def test_ErrorCollector_error_definitions(src, expected): |
211 | 301 | ) |
212 | 302 | ], |
213 | 303 | ), |
| 304 | + ( |
| 305 | + cleandoc( |
| 306 | + """ |
| 307 | + from exasol import error |
| 308 | + from exasol.error import Parameter |
| 309 | +
|
| 310 | + var = input("description: ") |
| 311 | +
|
| 312 | + error1 = error.ExaError( |
| 313 | + "E-TEST-1", |
| 314 | + var, |
| 315 | + ["mitigations"], |
| 316 | + {"param": Parameter("value", "")}, |
| 317 | + ) |
| 318 | + """ |
| 319 | + ), |
| 320 | + [ |
| 321 | + Error( |
| 322 | + code=INVALID_ERROR_CODE_DEFINITION.identifier, |
| 323 | + message=INVALID_ERROR_CODE_DEFINITION.message, |
| 324 | + mitigations=INVALID_ERROR_CODE_DEFINITION.mitigations, |
| 325 | + parameters={ |
| 326 | + "error_element": "message", |
| 327 | + "file": "<Unknown>", |
| 328 | + "line": "8", |
| 329 | + "defined_type": f"<class '{AST_NAME_CLASS}'>", |
| 330 | + }, |
| 331 | + ) |
| 332 | + ], |
| 333 | + ), |
| 334 | + ( |
| 335 | + cleandoc( |
| 336 | + """ |
| 337 | + from exasol import error |
| 338 | + from exasol.error import Parameter |
| 339 | +
|
| 340 | + var = input("description: ") |
| 341 | +
|
| 342 | + error1 = error.ExaError( |
| 343 | + "E-TEST-1", |
| 344 | + var, |
| 345 | + ["mitigations"], |
| 346 | + {"param": Parameter("value", None)}, |
| 347 | + ) |
| 348 | + """ |
| 349 | + ), |
| 350 | + [ |
| 351 | + Error( |
| 352 | + code=INVALID_ERROR_CODE_DEFINITION.identifier, |
| 353 | + message=INVALID_ERROR_CODE_DEFINITION.message, |
| 354 | + mitigations=INVALID_ERROR_CODE_DEFINITION.mitigations, |
| 355 | + parameters={ |
| 356 | + "error_element": "message", |
| 357 | + "file": "<Unknown>", |
| 358 | + "line": "8", |
| 359 | + "defined_type": f"<class '{AST_NAME_CLASS}'>", |
| 360 | + }, |
| 361 | + ) |
| 362 | + ], |
| 363 | + ), |
| 364 | + ( |
| 365 | + cleandoc( |
| 366 | + """ |
| 367 | + from exasol import error |
| 368 | + from exasol.error import Parameter |
| 369 | +
|
| 370 | + var = input("description: ") |
| 371 | +
|
| 372 | + error1 = error.ExaError( |
| 373 | + "E-TEST-1", |
| 374 | + var, |
| 375 | + ["mitigations"], |
| 376 | + {"param": Parameter("value")}, |
| 377 | + ) |
| 378 | + """ |
| 379 | + ), |
| 380 | + [ |
| 381 | + Error( |
| 382 | + code=INVALID_ERROR_CODE_DEFINITION.identifier, |
| 383 | + message=INVALID_ERROR_CODE_DEFINITION.message, |
| 384 | + mitigations=INVALID_ERROR_CODE_DEFINITION.mitigations, |
| 385 | + parameters={ |
| 386 | + "error_element": "message", |
| 387 | + "file": "<Unknown>", |
| 388 | + "line": "8", |
| 389 | + "defined_type": f"<class '{AST_NAME_CLASS}'>", |
| 390 | + }, |
| 391 | + ) |
| 392 | + ], |
| 393 | + ), |
214 | 394 | ], |
215 | 395 | ) |
216 | 396 | def test_ErrorCollector_errors(src, expected): |
@@ -256,6 +436,78 @@ def test_ErrorCollector_errors(src, expected): |
256 | 436 | ), |
257 | 437 | [], |
258 | 438 | ), |
| 439 | + ( |
| 440 | + cleandoc( |
| 441 | + """ |
| 442 | + from exasol import error |
| 443 | + from exasol.error import Parameter |
| 444 | + |
| 445 | + var = input("description: ") |
| 446 | + |
| 447 | + error1 = error.ExaError( |
| 448 | + "E-TEST-1", |
| 449 | + "this is an error", |
| 450 | + ["no mitigation available"], |
| 451 | + {"param": Parameter("value", "description")}, |
| 452 | + ) |
| 453 | + """ |
| 454 | + ), |
| 455 | + [], |
| 456 | + ), |
| 457 | + ( |
| 458 | + cleandoc( |
| 459 | + """ |
| 460 | + from exasol import error |
| 461 | + from exasol.error import Parameter |
| 462 | +
|
| 463 | + var = input("description: ") |
| 464 | +
|
| 465 | + error1 = error.ExaError( |
| 466 | + "E-TEST-1", |
| 467 | + "this is an error", |
| 468 | + ["no mitigation available"], |
| 469 | + {"param": Parameter("value", "")}, |
| 470 | + ) |
| 471 | + """ |
| 472 | + ), |
| 473 | + [], |
| 474 | + ), |
| 475 | + ( |
| 476 | + cleandoc( |
| 477 | + """ |
| 478 | + from exasol import error |
| 479 | + from exasol.error import Parameter |
| 480 | +
|
| 481 | + var = input("description: ") |
| 482 | +
|
| 483 | + error1 = error.ExaError( |
| 484 | + "E-TEST-1", |
| 485 | + "this is an error", |
| 486 | + ["no mitigation available"], |
| 487 | + {"param": Parameter("value", None)}, |
| 488 | + ) |
| 489 | + """ |
| 490 | + ), |
| 491 | + [], |
| 492 | + ), |
| 493 | + ( |
| 494 | + cleandoc( |
| 495 | + """ |
| 496 | + from exasol import error |
| 497 | + from exasol.error import Parameter |
| 498 | +
|
| 499 | + var = input("description: ") |
| 500 | +
|
| 501 | + error1 = error.ExaError( |
| 502 | + "E-TEST-1", |
| 503 | + "this is an error", |
| 504 | + ["no mitigation available"], |
| 505 | + {"param": Parameter("value")}, |
| 506 | + ) |
| 507 | + """ |
| 508 | + ), |
| 509 | + [], |
| 510 | + ), |
259 | 511 | ], |
260 | 512 | ) |
261 | 513 | def test_ErrorCollector_warnings(src, expected): |
|
0 commit comments