Пример #1
0
 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}")
Пример #2
0
 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())
Пример #3
0
 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)
Пример #4
0
 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))
Пример #5
0
 def undo(self):
     for connection_dict in self._connections_dict.values():
         self._project.add_connection(Connection.from_dict(connection_dict))
Пример #6
0
 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))