Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testbench2robotframework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

from .testbench2robotframework import testbench2robotframework # noqa: F401

__version__ = "0.8.0a1"
__version__ = "0.8.0b2"
5 changes: 5 additions & 0 deletions testbench2robotframework/json_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def metadata(self) -> dict[str, str]:
"UniqueID": self.details.uniqueID,
"Name": self.details.name,
"Numbering": self.details.numbering,
"Path": self.details.path,
}


Expand All @@ -49,6 +50,10 @@ def get_structure_tree_path(self) -> Path:
if not tov_path.exists():
sys.exit(f"Neither {cycle_path} nor {tov_path} found.")
return tov_path

def get_project_json(self) -> Optional[dict]:
project_path = Path(self.json_dir) / "project.json"
return read_json(str(project_path))

@property
def test_theme_tree(self) -> TestStructureTree:
Expand Down
2 changes: 2 additions & 0 deletions testbench2robotframework/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ class TestCaseSetDetails:
key: str
numbering: str
uniqueID: str
path:str
name: str
spec: TestCaseSetSpecificationSummary
testCases: list[TestCaseSummary]
Expand All @@ -522,6 +523,7 @@ def from_dict(cls, dictionary) -> TestCaseSetDetails:
numbering=dictionary.get("numbering", ""),
uniqueID=dictionary.get("uniqueID", ""),
name=dictionary.get("name", ""),
path=dictionary.get("path", ""),
spec=TestCaseSetSpecificationSummary.from_dict(dictionary.get("spec", {})),
exec=TestCaseSetExecutionSummary.from_dict(dictionary.get("exec", {}))
if dictionary.get("exec")
Expand Down
7 changes: 7 additions & 0 deletions testbench2robotframework/result_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ def end_test(self, test: TestCase):
compound_interactions = list(
self._get_interactions_by_type(itb_test_case.interactions, InteractionType.Compound)
)
textual_interactions = list(
self._get_interactions_by_type(itb_test_case.interactions, InteractionType.Textual)
)
for step in textual_interactions:
if step.exec is None:
step.exec = InteractionExecutionSummary.from_dict({})
step.exec.verdict = InteractionVerdict.Skipped
self._set_atomic_interactions_execution_result(atomic_interactions, self.test_chain)
for interaction in compound_interactions:
self._set_compound_interaction_execution_result(interaction)
Expand Down
13 changes: 11 additions & 2 deletions testbench2robotframework/testbench2rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ def create_test_suites(
test_case_set_catalog: dict[str, TestCaseSet],
path_resolver: PathResolver,
config: Configuration,
project: str | None,
tov: str | None,
cycle: str | None
) -> dict[str, File]:
if not Group:
if config.compound_interaction_logging == CompoundInteractionLogging.GROUP:
Expand All @@ -526,7 +529,7 @@ def create_test_suites(
test_suites = {}
for uid, test_case_set in test_case_set_catalog.items():
test_suites[uid] = RobotSuiteFileBuilder(
test_case_set, tcs_paths[uid], config
test_case_set, tcs_paths[uid], config, project, tov, cycle
).create_test_suite_file()
tt_paths = path_resolver.tt_paths
for uid, test_theme in path_resolver.tt_catalog.items():
Expand Down Expand Up @@ -586,11 +589,14 @@ def create_meta_data(name, value):

class RobotSuiteFileBuilder:
def __init__(
self, test_case_set: TestCaseSet, tcs_path: PurePath, config: Configuration
self, test_case_set: TestCaseSet, tcs_path: PurePath, config: Configuration, project: str | None, tov: str | None, cycle: str | None
) -> None:
self.test_case_set = test_case_set
self.tcs_path = tcs_path
self.config = config
self.project = project
self.tov = tov
self.cycle = cycle
self._rf_test_cases: list[RfTestCase] = [
RfTestCase(test_case_details=test_case, config=config)
for test_case in self.test_case_set.test_cases.values()
Expand Down Expand Up @@ -764,6 +770,9 @@ def _create_setting_section(self) -> SettingSection:
setting_section.body.extend(self._create_rf_resource_imports(subdivisions))
setting_section.body.extend(self._create_rf_unknown_imports(subdivisions))
setting_section_meta_data = self.test_case_set.metadata
setting_section.body.append(create_meta_data("Project", self.project))
setting_section.body.append(create_meta_data("TOV", self.tov))
setting_section.body.append(create_meta_data("Cycle", self.cycle))
setting_section.body.extend(
[
create_meta_data(metadata_name, metadata_value)
Expand Down
9 changes: 7 additions & 2 deletions testbench2robotframework/testbench2robotframework.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def testbench2robotframework(testbench_report: str, config: dict):
setup_logger(configuration)
logger.debug("Configuration loaded.")
testbench_report = Path(testbench_report)
temp_dir = None
try:
if is_zip_file(testbench_report):
temp_dir = tempfile.TemporaryDirectory(dir=Path.cwd())
Expand All @@ -33,14 +34,18 @@ def testbench2robotframework(testbench_report: str, config: dict):
tuple(reader.get_test_case_set_catalog().keys()),
configuration.log_suite_numbering,
)
project_information = reader.get_project_json()
project = project_information.get("name") if project_information else None
tov = project_information.get("projectContext", {}).get("tovName") if project_information else None
cycle = project_information.get("projectContext", {}).get("cycleName") if project_information else None
test_suites = create_test_suites(
reader.get_test_case_set_catalog(), path_resolver, configuration
reader.get_test_case_set_catalog(), path_resolver, configuration, project, tov, cycle
)
if not test_suites:
logger.warning("There are no test suites in the exported TestBench Projekt.")
return
write_test_suites(test_suites, configuration)
except Exception as exception:
if temp_dir:
if temp_dir is not None:
temp_dir.cleanup()
raise exception