From 34c79d3a157ca59bf61cd7e26ea1b71e5a761873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavlin=20Poli=C4=8Dar?= Date: Fri, 27 Oct 2023 10:37:59 +0200 Subject: [PATCH] owtsne: fix tests, use simulate util for combobox --- .../widgets/unsupervised/tests/test_owtsne.py | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Orange/widgets/unsupervised/tests/test_owtsne.py b/Orange/widgets/unsupervised/tests/test_owtsne.py index 18f12a43c66..89aacda108d 100644 --- a/Orange/widgets/unsupervised/tests/test_owtsne.py +++ b/Orange/widgets/unsupervised/tests/test_owtsne.py @@ -16,6 +16,7 @@ from Orange.widgets.tests.base import ( WidgetTest, WidgetOutputsTestMixin, ProjectionWidgetTestMixin ) +from Orange.widgets.tests.utils import simulate from Orange.widgets.unsupervised.owtsne import OWtSNE, TSNERunner, Task, prepare_tsne_obj @@ -779,25 +780,29 @@ def test_controls_ignored_by_distance_matrix_retain_values_on_table_signal(self) table signals.""" w = self.widget + # SEND IRIS DATA + # Set some parameters self.send_signal(w.Inputs.data, self.iris) - w.normalize_cbx.setChecked(True) + w.normalize_cbx.setChecked(False) w.pca_preprocessing_cbx.setChecked(True) w.pca_component_slider.setValue(3) - w.initialization_combo.setCurrentIndex(0) - w.distance_metric_combo.setCurrentIndex(2) + simulate.combobox_activate_index(w.initialization_combo, 0) + simulate.combobox_activate_index(w.distance_metric_combo, 2) w.perplexity_spin.setValue(42) - # Disconnect data, save context settings + + # Disconnect data self.send_signal(w.Inputs.data, None) - # Send distances signal + # SEND IRIS DISTANCES self.send_signal(w.Inputs.distances, self.iris_distances) - + # Check that distance-related controls are disabled self.assertFalse(w.normalize_cbx.isEnabled()) self.assertFalse(w.pca_preprocessing_cbx.isEnabled()) self.assertFalse(w.pca_component_slider.isEnabled()) self.assertFalse(w.initialization_combo.isEnabled()) + # Only spectral layout is supported when we have distances self.assertEqual(w.initialization_combo.currentText(), "Spectral") self.assertFalse(w.distance_metric_combo.isEnabled()) @@ -805,14 +810,19 @@ def test_controls_ignored_by_distance_matrix_retain_values_on_table_signal(self) self.assertTrue(w.perplexity_spin.isEnabled()) self.assertEqual(w.perplexity_spin.value(), 42) - # Disconnect signal, the context settings should not be overridden + + # Disconnect distances self.send_signal(w.Inputs.distances, None) - # Send data signal, the data-only settings should be restored + # SEND IRIS DATA + # The distance-related settings should be restored from when we sent in + # the data, and not overridden by the settings automatically set by the + # widget when we passed in the distances signal self.send_signal(w.Inputs.data, self.iris) + # Check that the parameters are restored self.assertTrue(w.normalize_cbx.isEnabled()) - self.assertTrue(w.normalize_cbx.isChecked()) + self.assertFalse(w.normalize_cbx.isChecked()) self.assertTrue(w.pca_preprocessing_cbx.isEnabled()) self.assertTrue(w.pca_preprocessing_cbx.isChecked())