main - fix: Change BlockModel key to name

This commit is contained in:
Yoel Bassin 2025-04-27 17:16:13 +03:00
parent ac4105b210
commit 6d6e4d0fc2
3 changed files with 5 additions and 9 deletions

View File

@ -46,10 +46,7 @@ class FlowGraphMiddleware(ElementMiddleware):
@property @property
def blocks(self) -> list[BlockModel]: def blocks(self) -> list[BlockModel]:
return [ return [BlockModel.from_block(block) for block in self._flowgraph.blocks]
BlockModel(key=block.key, label=block.label)
for block in self._flowgraph.blocks
]
def add_block( def add_block(
self, block_type: str, block_name: Optional[str] = None self, block_type: str, block_name: Optional[str] = None

View File

@ -20,11 +20,11 @@ class BlockTypeModel(BaseModel):
class BlockModel(BaseModel): class BlockModel(BaseModel):
label: str label: str
key: str name: str
@classmethod @classmethod
def from_block(cls, block: Block) -> BlockModel: def from_block(cls, block: Block) -> BlockModel:
return cls(label=block.label, key=block.name) return cls(label=block.label, name=block.name)
class ParamModel(BaseModel): class ParamModel(BaseModel):

View File

@ -18,8 +18,7 @@ def flowgraph_middleware(platform_middleware: PlatformMiddleware):
@pytest.fixture @pytest.fixture
def initial_blocks(flowgraph_middleware: FlowGraphMiddleware): def initial_blocks(flowgraph_middleware: FlowGraphMiddleware):
return [ return [
BlockModel(key=block.key, label=block.label) BlockModel.from_block(block) for block in flowgraph_middleware._flowgraph.blocks
for block in flowgraph_middleware._flowgraph.blocks
] ]
@ -34,7 +33,7 @@ def test_flowgraph_block_addition_and_removal(
blocks = flowgraph_middleware.blocks blocks = flowgraph_middleware.blocks
assert all(b in blocks for b in initial_blocks) assert all(b in blocks for b in initial_blocks)
assert any(b.key == block_key for b in blocks) assert any(b.name == explicit_name for b in blocks)
flowgraph_middleware.remove_block(explicit_name) flowgraph_middleware.remove_block(explicit_name)