@@ -12,83 +12,83 @@ def test_toolbar_adapter_outside_freecad(self):
12
12
with self .assertRaises (RuntimeError ):
13
13
ToolbarAdapter ()
14
14
15
- @patch ("addonmanager_toolbar_adapter.fci.ParamGet " )
15
+ @patch ("addonmanager_toolbar_adapter.fci.FreeCAD " )
16
16
def test_toolbar_adapter_inside_freecad (self , _ ):
17
17
"""When run inside FreeCAD, this class should instantiate correctly"""
18
18
ToolbarAdapter ()
19
19
20
- @patch ("addonmanager_toolbar_adapter.fci.ParamGet " )
21
- def test_get_toolbars (self , mock_param_get ):
20
+ @patch ("addonmanager_toolbar_adapter.fci.FreeCAD " )
21
+ def test_get_toolbars (self , mock_freecad : MagicMock ):
22
22
"""Get a list of toolbars out of the FreeCAD preferences system"""
23
- mock_param_get ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
24
- mock_param_get ().GetGroup = Mock (
23
+ mock_freecad . ParamGet ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
24
+ mock_freecad . ParamGet ().GetGroup = Mock (
25
25
side_effect = ["Toolbar1" , "Toolbar2" , "Toolbar3" , "Toolbar4" ]
26
26
)
27
27
toolbars = ToolbarAdapter ().get_toolbars ()
28
28
self .assertEqual (["Toolbar1" , "Toolbar2" , "Toolbar3" ], toolbars )
29
29
30
- @patch ("addonmanager_toolbar_adapter.fci.ParamGet " )
31
- def test_get_toolbar_with_name_good (self , mock_param_get ):
30
+ @patch ("addonmanager_toolbar_adapter.fci.FreeCAD " )
31
+ def test_get_toolbar_with_name_good (self , mock_freecad : MagicMock ):
32
32
"""Find a specific toolbar with a given name"""
33
- mock_param_get ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
34
- mock_param_get ().GetGroup = MagicMock ()
35
- mock_param_get ().GetGroup ().GetString = MagicMock (
33
+ mock_freecad . ParamGet ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
34
+ mock_freecad . ParamGet ().GetGroup = MagicMock ()
35
+ mock_freecad . ParamGet ().GetGroup ().GetString = MagicMock (
36
36
side_effect = ["Toolbar1" , "Toolbar2" , "Toolbar3" ]
37
37
)
38
38
toolbars = ToolbarAdapter ().get_toolbar_with_name ("Toolbar2" )
39
39
self .assertIsNotNone (toolbars )
40
40
41
- @patch ("addonmanager_toolbar_adapter.fci.ParamGet " )
42
- def test_get_toolbar_with_name_no_match (self , mock_param_get ):
41
+ @patch ("addonmanager_toolbar_adapter.fci.FreeCAD " )
42
+ def test_get_toolbar_with_name_no_match (self , mock_freecad : MagicMock ):
43
43
"""Don't find a toolbar that doesn't match the name"""
44
- mock_param_get ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
45
- mock_param_get ().GetGroup = MagicMock ()
46
- mock_param_get ().GetGroup ().GetString = MagicMock (
44
+ mock_freecad . ParamGet ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
45
+ mock_freecad . ParamGet ().GetGroup = MagicMock ()
46
+ mock_freecad . ParamGet ().GetGroup ().GetString = MagicMock (
47
47
side_effect = ["Toolbar1" , "Toolbar2" , "Toolbar3" ]
48
48
)
49
49
toolbars = ToolbarAdapter ().get_toolbar_with_name ("Toolbar4" )
50
50
self .assertIsNone (toolbars )
51
51
52
- @patch ("addonmanager_toolbar_adapter.fci.ParamGet " )
53
- def test_check_for_toolbar_with_match (self , mock_param_get ):
54
- mock_param_get ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
55
- mock_param_get ().GetGroup = MagicMock ()
56
- mock_param_get ().GetGroup ().GetString = MagicMock (
52
+ @patch ("addonmanager_toolbar_adapter.fci.FreeCAD " )
53
+ def test_check_for_toolbar_with_match (self , mock_freecad : MagicMock ):
54
+ mock_freecad . ParamGet ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
55
+ mock_freecad . ParamGet ().GetGroup = MagicMock ()
56
+ mock_freecad . ParamGet ().GetGroup ().GetString = MagicMock (
57
57
side_effect = ["Toolbar1" , "Toolbar2" , "Toolbar3" ]
58
58
)
59
59
self .assertTrue (ToolbarAdapter ().check_for_toolbar ("Toolbar2" ))
60
60
61
- @patch ("addonmanager_toolbar_adapter.fci.ParamGet " )
62
- def test_check_for_toolbar_without_match (self , mock_param_get ):
63
- mock_param_get ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
64
- mock_param_get ().GetGroup = MagicMock ()
65
- mock_param_get ().GetGroup ().GetString = MagicMock (
61
+ @patch ("addonmanager_toolbar_adapter.fci.FreeCAD " )
62
+ def test_check_for_toolbar_without_match (self , mock_freecad : MagicMock ):
63
+ mock_freecad . ParamGet ().GetGroups = Mock (return_value = ["A" , "B" , "C" ])
64
+ mock_freecad . ParamGet ().GetGroup = MagicMock ()
65
+ mock_freecad . ParamGet ().GetGroup ().GetString = MagicMock (
66
66
side_effect = ["Toolbar1" , "Toolbar2" , "Toolbar3" ]
67
67
)
68
68
self .assertFalse (ToolbarAdapter ().check_for_toolbar ("Toolbar4" ))
69
69
70
- @patch ("addonmanager_toolbar_adapter.fci.ParamGet " )
71
- def test_create_new_custom_toolbar_basic_name (self , mock_param_get ):
70
+ @patch ("addonmanager_toolbar_adapter.fci.FreeCAD " )
71
+ def test_create_new_custom_toolbar_basic_name (self , mock_freecad : MagicMock ):
72
72
"""If no custom toolbar exists yet, then the new toolbar uses the most basic name form"""
73
73
toolbar = ToolbarAdapter ().create_new_custom_toolbar ()
74
74
toolbar .SetString .assert_called_with ("Name" , "Auto-Created Macro Toolbar" )
75
- mock_param_get ().GetGroup .assert_called_with ("Custom_1" )
75
+ mock_freecad . ParamGet ().GetGroup .assert_called_with ("Custom_1" )
76
76
77
- @patch ("addonmanager_toolbar_adapter.fci.ParamGet " )
78
- def test_create_new_custom_toolbar_name_taken (self , mock_param_get ):
77
+ @patch ("addonmanager_toolbar_adapter.fci.FreeCAD " )
78
+ def test_create_new_custom_toolbar_name_taken (self , mock_freecad : MagicMock ):
79
79
"""If no custom toolbar exists yet, then the new toolbar uses the most basic name form"""
80
80
with patch (
81
81
"addonmanager_toolbar_adapter.ToolbarAdapter.check_for_toolbar"
82
82
) as mock_check_for_toolbar :
83
83
mock_check_for_toolbar .side_effect = [True , True , False ]
84
84
toolbar = ToolbarAdapter ().create_new_custom_toolbar ()
85
85
toolbar .SetString .assert_called_with ("Name" , "Auto-Created Macro Toolbar (3)" )
86
- mock_param_get ().GetGroup .assert_called_with ("Custom_1" )
86
+ mock_freecad . ParamGet ().GetGroup .assert_called_with ("Custom_1" )
87
87
88
- @patch ("addonmanager_toolbar_adapter.fci.ParamGet " )
89
- def test_create_new_custom_toolbar_group_name_taken (self , mock_param_get ):
88
+ @patch ("addonmanager_toolbar_adapter.fci.FreeCAD " )
89
+ def test_create_new_custom_toolbar_group_name_taken (self , mock_freecad : MagicMock ):
90
90
"""If no custom toolbar exists yet, then the new toolbar uses the most basic name form"""
91
- mock_param_get ().GetGroups = Mock (return_value = ["Custom_1" , "Custom_2" , "Custom_3" ])
91
+ mock_freecad . ParamGet ().GetGroups = Mock (return_value = ["Custom_1" , "Custom_2" , "Custom_3" ])
92
92
toolbar = ToolbarAdapter ().create_new_custom_toolbar ()
93
93
toolbar .SetString .assert_called_with ("Name" , "Auto-Created Macro Toolbar" )
94
- mock_param_get ().GetGroup .assert_called_with ("Custom_4" )
94
+ mock_freecad . ParamGet ().GetGroup .assert_called_with ("Custom_4" )
0 commit comments