From b3be1ce23f679b751e0f9016ee601ba081d3179a Mon Sep 17 00:00:00 2001 From: "Chi Song (from Dev Box)" Date: Wed, 2 Oct 2024 20:21:53 -0700 Subject: [PATCH] fix UT to load from a real file --- .gitignore | 2 ++ selftests/test_transformer.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d57639336..f8ae3be29 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ dist # Local working file notes + +selftests/test_runbook.yml \ No newline at end of file diff --git a/selftests/test_transformer.py b/selftests/test_transformer.py index 5fe899157..8d221ee9f 100644 --- a/selftests/test_transformer.py +++ b/selftests/test_transformer.py @@ -6,6 +6,7 @@ from pathlib import Path from typing import Any, Dict, List, Type from unittest import TestCase +import yaml from dataclasses_json import dataclass_json from lisa import LisaException, constants, schema, transformer @@ -179,7 +180,9 @@ class TestTransformerCase(TestCase): transformers_data: List[Any] = [ x.to_dict() for x in transformers # type:ignore ] - runbook_builder = RunbookBuilder(Path("mock_runbook.yml")) + test_runbook_path = Path(__file__).parent / "test_runbook.yml" + + runbook_builder = RunbookBuilder(test_runbook_path) runbook_builder._raw_data = { constants.TRANSFORMER: transformers_data, } @@ -187,6 +190,10 @@ class TestTransformerCase(TestCase): "v0": VariableEntry("v0", "original"), "va": VariableEntry("va", "original"), } + + # write to file for reloading in runbook.derive method. + with open(test_runbook_path, "w") as file: + yaml.dump(runbook_builder._raw_data, file) return runbook_builder def _generate_transformers_runbook(self, count: int) -> List[schema.Transformer]: