def test_variable_editor(self): w = VariableEditor() self.assertIs(w.get_data(), None) v = StringVariable(name="S") v.attributes.update({"A": 1, "B": "b"}, ) w.set_data(v) self.assertEqual(w.name_edit.text(), v.name) self.assertEqual(w.labels_model.get_dict(), v.attributes) self.assertTrue(w.is_same()) w.set_data(None) self.assertEqual(w.name_edit.text(), "") self.assertEqual(w.labels_model.get_dict(), {}) self.assertIs(w.get_data(), None)
def test_variable_editor(self): w = VariableEditor() self.assertIs(w.get_data(), None) v = StringVariable(name="S") v.attributes.update({"A": 1, "B": "b"},) w.set_data(v) self.assertEqual(w.name_edit.text(), v.name) self.assertEqual(w.labels_model.get_dict(), v.attributes) self.assertTrue(w.is_same()) w.set_data(None) self.assertEqual(w.name_edit.text(), "") self.assertEqual(w.labels_model.get_dict(), {}) self.assertIs(w.get_data(), None)
def test_variable_editor(self): w = VariableEditor() self.assertEqual(w.get_data(), (None, [])) v = String("S", (("A", "1"), ("B", "b"))) w.set_data(v, []) self.assertEqual(w.name_edit.text(), v.name) self.assertEqual(w.labels_model.get_dict(), {"A": "1", "B": "b"}) self.assertEqual(w.get_data(), (v, [])) w.set_data(None) self.assertEqual(w.name_edit.text(), "") self.assertEqual(w.labels_model.get_dict(), {}) self.assertEqual(w.get_data(), (None, [])) w.set_data(v, [Rename("T"), Annotate((("a", "1"), ("b", "2")))]) self.assertEqual(w.name_edit.text(), "T") self.assertEqual(w.labels_model.rowCount(), 2) add = w.findChild(QAction, "action-add-label") add.trigger() remove = w.findChild(QAction, "action-delete-label") remove.trigger()