1
+ import unittest
2
+ from Orange .data import Table
3
+ from Orange .widgets .tests .base import WidgetTest
4
+ from orangecontrib .single_cell .widgets .owspatialautocorrelation import OWSpatialAutocorrelation
5
+ from Orange .widgets .utils .concurrent import TaskState
6
+
7
+
8
+ class TestOWSpatialAutocorrelation (WidgetTest ):
9
+ def setUp (self ):
10
+ self .widget = self .create_widget (OWSpatialAutocorrelation )
11
+
12
+ def test_input_data (self ):
13
+ data = Table ("iris" )
14
+ self .widget .set_data (data )
15
+ self .assertEqual (self .widget .data , data )
16
+
17
+ def test_feature_selection (self ):
18
+ data = Table ("iris" )
19
+ self .widget .set_data (data )
20
+ self .widget .feature_x_combo .setCurrentIndex (1 )
21
+ self .widget .feature_y_combo .setCurrentIndex (2 )
22
+ self .assertEqual (self .widget .feature_x , "sepal width" )
23
+ self .assertEqual (self .widget .feature_y , "petal length" )
24
+
25
+ def test_method_selection (self ):
26
+ self .widget .method = "Geary C"
27
+ self .assertEqual (self .widget .method , "Geary C" )
28
+
29
+ def test_k_neighbors_input (self ):
30
+ self .widget .k_input .setText ("10" )
31
+ self .widget ._on_k_changed ()
32
+ self .assertEqual (self .widget .k_neighbors , 10 )
33
+
34
+ def test_auto_commit (self ):
35
+ self .widget .auto_commit = False
36
+ self .assertFalse (self .widget .auto_commit )
37
+
38
+ def test_calculate (self ):
39
+ data = Table ("iris" )
40
+ self .widget .set_data (data )
41
+ self .widget .feature_x_combo .setCurrentIndex (0 )
42
+ self .widget .feature_y_combo .setCurrentIndex (1 )
43
+ self .widget .k_input .setText ("5" )
44
+ self .widget ._on_k_changed ()
45
+ self .widget .calculate (TaskState ())
46
+ self .assertIsNotNone (self .widget .adjacency_matrix )
47
+
48
+
49
+ if __name__ == "__main__" :
50
+ unittest .main ()
0 commit comments