def create_block(self, diagram_control=None): if diagram_control is None: diagram_control = self.create_diagram_control() System() block_model = BlockModel() System.add_port(self.create_port()) block_model.ports = [{ "type": "Test", "label": "Click", "conn_type": "Input", "name": "0" }, { "type": "Test", "label": "Click", "conn_type": "Output", "name": "1" }, { "type": "Test", "label": "Click", "conn_type": "Input", "name": "2" }, { "type": "Test", "label": "Click", "conn_type": "Output", "name": "3" }] block_model.help = "Test" block_model.label = "Test" block_model.color = "200:200:25:150" block_model.group = "Test" block_model.codes = {"code0": "Test", "Code1": "Test", "Code2": "Test"} block_model.type = "Test" block_model.language = "Test" block_model.properties = [{ "name": "test", "label": "Test", "value": "0", "type": MOSAICODE_FLOAT }] block_model.extension = "Test" block_model.file = None result = BlockControl.load_ports(block_model, System.get_ports()) System.add_block(block_model) self.assertEquals(result[1], "Success") self.assertEquals(result[0], True) self.assertEquals(len(block_model.ports), 4) block = Block(diagram_control.diagram, block_model) self.assertEquals(len(block.ports), 4) return block
def test_add_port(self): PortControl() port = self.create_port() PortControl.delete_port(port.type) System() PortControl.add_port(self.create_port()) System.reload() PortControl.delete_port(port.type) System.add_port(port) PortControl.delete_port(port.type)