Skip to content

Commit 1bd32e9

Browse files
authored
add set_comments API (#15)
1 parent 3c23935 commit 1bd32e9

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/ansys/dynamicreporting/core/utils/report_objects.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,18 @@ def set_html(self, value=""):
16341634
else:
16351635
raise ValueError(f"Error: HTML not supported on the report type {self.report_type}")
16361636

1637+
def set_comments(self, value=""):
1638+
if "Layout:" in self.report_type:
1639+
if isinstance(value, str):
1640+
d = json.loads(self.params)
1641+
d["comments"] = value
1642+
self.params = json.dumps(d)
1643+
return
1644+
else:
1645+
raise ValueError("Error: input needs to be a string")
1646+
else:
1647+
raise ValueError(f"Error: Comments not supported on the report type {self.report_type}")
1648+
16371649
def get_transpose(self):
16381650
if "Layout:" in self.report_type:
16391651
if "transpose" in json.loads(self.params):

tests/test_report_objects.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,17 @@ def test_layout_html() -> bool:
366366
assert success
367367

368368

369+
def test_set_comments() -> None:
370+
a = ro.LayoutREST()
371+
a.set_comments(value="lololol")
372+
success = False
373+
try:
374+
a.set_comments(value=4)
375+
except ValueError as e:
376+
success = "input needs to be a string" in str(e)
377+
assert success
378+
379+
369380
def test_layout_transport() -> bool:
370381
a = ro.LayoutREST()
371382
zero = a.get_transpose()

0 commit comments

Comments
 (0)