diff --git a/src/ansys/dynamicreporting/core/utils/report_objects.py b/src/ansys/dynamicreporting/core/utils/report_objects.py index db549896a..d8e5e4ba3 100644 --- a/src/ansys/dynamicreporting/core/utils/report_objects.py +++ b/src/ansys/dynamicreporting/core/utils/report_objects.py @@ -1634,6 +1634,18 @@ def set_html(self, value=""): else: raise ValueError(f"Error: HTML not supported on the report type {self.report_type}") + def set_comments(self, value=""): + if "Layout:" in self.report_type: + if isinstance(value, str): + d = json.loads(self.params) + d["comments"] = value + self.params = json.dumps(d) + return + else: + raise ValueError("Error: input needs to be a string") + else: + raise ValueError(f"Error: Comments not supported on the report type {self.report_type}") + def get_transpose(self): if "Layout:" in self.report_type: if "transpose" in json.loads(self.params): diff --git a/tests/test_report_objects.py b/tests/test_report_objects.py index 12b13e352..a49badf2c 100755 --- a/tests/test_report_objects.py +++ b/tests/test_report_objects.py @@ -366,6 +366,17 @@ def test_layout_html() -> bool: assert success +def test_set_comments() -> None: + a = ro.LayoutREST() + a.set_comments(value="lololol") + success = False + try: + a.set_comments(value=4) + except ValueError as e: + success = "input needs to be a string" in str(e) + assert success + + def test_layout_transport() -> bool: a = ro.LayoutREST() zero = a.get_transpose()