feat(generate_cli): RPC API from content widget can be merged with the RPC API of the container widget statically

This commit is contained in:
2026-03-05 18:12:33 +01:00
parent 010373fd5b
commit 758956be09
9 changed files with 425 additions and 12 deletions
@@ -34,6 +34,31 @@ class MockBECFigure:
"""Remove a plot from the figure."""
class MockContentWidget:
USER_ACCESS = ["list_profiles", "mode", "mode.setter"]
def list_profiles(self) -> list[str]:
"""List profiles."""
return []
@property
def mode(self) -> str:
"""Current mode."""
return "creator"
@mode.setter
def mode(self, value: str) -> None:
_ = value
class MockViewWithContent:
USER_ACCESS = ["activate"]
RPC_CONTENT_CLASS = MockContentWidget
def activate(self):
"""Activate view."""
def test_client_generator_with_black_formatting():
generator = ClientGenerator(base=True)
container = BECClassContainer()
@@ -228,6 +253,16 @@ def test_generate_content_for_class():
assert "Test method" in generator.content
def test_generate_content_for_class_uses_rpc_content_class_user_access():
generator = ClientGenerator()
generator.generate_content_for_class(MockViewWithContent)
assert "def activate(self):" in generator.content
assert "def list_profiles(self) -> list[str]:" in generator.content
assert "def mode(self) -> str:" in generator.content
assert "@mode.setter" in generator.content
def test_write_is_black_formatted(tmp_path):
"""
Test the write method of the ClientGenerator class.