|
1 | 1 | # Test methods with long descriptive names can omit docstrings |
2 | 2 | # pylint: disable=missing-docstring, protected-access |
| 3 | +import unittest |
3 | 4 | import warnings |
4 | 5 |
|
5 | 6 | import numpy as np |
6 | 7 |
|
7 | 8 | from AnyQt.QtCore import QPoint, Qt |
| 9 | +from AnyQt.QtGui import QColor |
8 | 10 | from AnyQt.QtTest import QTest |
9 | 11 |
|
10 | 12 | import Orange.misc |
|
13 | 15 | from Orange.misc import DistMatrix |
14 | 16 | from Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin |
15 | 17 | from Orange.widgets.unsupervised.owhierarchicalclustering import \ |
16 | | - OWHierarchicalClustering |
| 18 | + OWHierarchicalClustering, SelectedLabelsModel |
17 | 19 |
|
18 | 20 |
|
19 | 21 | class TestOWHierarchicalClustering(WidgetTest, WidgetOutputsTestMixin): |
@@ -226,3 +228,16 @@ def test_many_values_warning(self): |
226 | 228 |
|
227 | 229 | self.send_signal(self.widget.Inputs.distances, None) |
228 | 230 | self.assertFalse(w.Warning.many_clusters.is_shown()) |
| 231 | + |
| 232 | + |
| 233 | +class TestSelectedLabelsModel(unittest.TestCase): |
| 234 | + def test_model_extend(self): |
| 235 | + model = SelectedLabelsModel() |
| 236 | + model[:] = ["1"] |
| 237 | + model.set_colors([QColor(Qt.blue)]) |
| 238 | + index = model.index(0) |
| 239 | + self.assertEqual(index.data(Qt.DisplayRole), "1") |
| 240 | + self.assertEqual(index.data(Qt.BackgroundRole), QColor(Qt.blue)) |
| 241 | + model[:]= ["1", "2"] |
| 242 | + index1 = model.index(1) |
| 243 | + self.assertEqual(index1.data(Qt.BackgroundRole), QColor()) # should be invalid color |
0 commit comments