def redo(self): if self._replaced_connection_dict is None: success = self._project.add_connection( Connection.from_dict(self._connection_dict)) if not success: self.setObsolete(True) else: self._project.replace_connection( Connection.from_dict(self._replaced_connection_dict), Connection.from_dict(self._connection_dict)) action = "add" if self._replaced_connection_dict is None else "replace" self.setText(f"{action} {self._connection_name}")
def test_serialization_without_filters(self): connection = Connection("source", "bottom", "destination", "top") connection_dict = connection.to_dict() restored = Connection.from_dict(connection_dict) self.assertEqual(restored.source, "source") self.assertEqual(restored.source_position, "bottom") self.assertEqual(restored.destination, "destination") self.assertEqual(restored.destination_position, "top") self.assertFalse(restored.has_filters())
def test_serialization_with_filters(self): filters = {"label": {"scenario_filter": {13: True}}} connection = Connection("source", "bottom", "destination", "top", filters) connection_dict = connection.to_dict() restored = Connection.from_dict(connection_dict) self.assertEqual(restored.source, "source") self.assertEqual(restored.source_position, "bottom") self.assertEqual(restored.destination, "destination") self.assertEqual(restored.destination_position, "top") self.assertTrue(restored.has_filters()) self.assertEqual(restored.resource_filters, filters)
def undo(self): if self._replaced_connection_dict is None: connection = self._project.find_connection(self._source_name, self._destination_name) self._project.remove_connection(connection) else: connection = self._project.find_connection(self._source_name, self._destination_name) self._project.replace_connection( connection, Connection.from_dict(self._replaced_connection_dict))
def undo(self): for connection_dict in self._connections_dict.values(): self._project.add_connection(Connection.from_dict(connection_dict))
def undo(self): self._project.make_and_add_project_items(self._items_dict, verbosity=False) for connection_dict in self._connection_dicts: self._project.add_connection(Connection.from_dict(connection_dict))