Skip to content

Commit

Permalink
refactor: validate module test and unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
0hsn committed Dec 29, 2024
1 parent 6c85e1e commit 71b1f68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
13 changes: 5 additions & 8 deletions chk/modules/validate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
AssertionEntityProperty,
get_schema_map,
)
from chk.modules.validate.entities import RunReport, ValidationTask
from chk.modules.validate.entities import ValidationTask
from chk.modules.validate.services import ValidatePresenter

VERSION_SCOPE = ["validation"]
Expand Down Expand Up @@ -136,7 +136,7 @@ def set_data_template(
)

@staticmethod
def process_data_template(variables: Variables) -> None:
def process_data_template(variables: Variables) -> None:
"""process data or template before assertion"""
data = variables[ValidationConfigNode.VAR_NODE.value]
tmp_variables = {
Expand Down Expand Up @@ -223,16 +223,14 @@ def call(file_ctx: FileContext, exec_ctx: ExecuteContext) -> ExecResponse:
)
except Exception as ex:
error_trace(exception=sys.exc_info()).error(ex)
return ExecResponse(file_ctx=file_ctx, exec_ctx=exec_ctx, exception=ex)
return ExecResponse(file_ctx=file_ctx, exec_ctx=exec_ctx, exception=ex, report={"is_success": False})

variable_doc = Variables()
VariableTableManager.handle(variable_doc, validate_doc, exec_ctx)
debug(variable_doc.data)

# handle passed data in asserts
ValidationDocumentSupport.set_data_template(
validate_doc, variable_doc, exec_ctx
)
ValidationDocumentSupport.set_data_template(validate_doc, variable_doc, exec_ctx)

ValidationDocumentSupport.process_data_template(variable_doc)
debug(variable_doc.data)
Expand All @@ -245,7 +243,7 @@ def call(file_ctx: FileContext, exec_ctx: ExecuteContext) -> ExecResponse:
run_rpt = AssertionEntryListRunner.test_run(assert_list, variable_doc.data)
except Exception as ex:
error_trace(exception=sys.exc_info()).error(ex)
return ExecResponse(file_ctx=file_ctx, exec_ctx=exec_ctx, exception=ex)
return ExecResponse(file_ctx=file_ctx, exec_ctx=exec_ctx, exception=ex, report={"is_success": False})

output_data = Variables(
{
Expand Down Expand Up @@ -276,7 +274,6 @@ def call(file_ctx: FileContext, exec_ctx: ExecuteContext) -> ExecResponse:
variables=variable_doc,
extra=run_rpt,
exposed=exposed_data,
exception=None,
report={
"is_success": run_rpt.count_fail == 0,
"count_all": len(validate_doc.asserts),
Expand Down
5 changes: 1 addition & 4 deletions tests/modules/validate/validate_module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ def test_fail_for_wrong_key() -> None:
)

er = call(file_ctx, exec_ctx)
import icecream
icecream.ic(er)

assert isinstance(er, ExecResponse)
icecream.ic(er.exception, type(er.exception))
# assert isinstance(er.exception, RuntimeError)
assert isinstance(er.exception, KeyError)

0 comments on commit 71b1f68

Please # to comment.