diff --git a/models/context.py b/models/context.py new file mode 100644 index 0000000..82f75c1 --- /dev/null +++ b/models/context.py @@ -0,0 +1,19 @@ +from typing import Any +from .itm import TestModel + + +class Context: + def __init__(self, config: TestModel): + self.config = config + self.variables: dict[str, str] = config.variables.copy() + self.extracted: dict[str, Any] = {} + + def resolve(self, template: str) -> str: + result = template + all_vars = {**self.variables, **self.extracted} + for key, value in all_vars.items(): + result = result.replace(f"{{{{{key}}}}}", str(value)) + return result + + def set_extracted(self, name: str, value: Any): + self.extracted[name] = value