1414try :
1515 import mock
1616 from mock import patch
17+ from mock import PropertyMock
1718except ImportError :
1819 from unittest .mock import MagicMock as mock
20+ from unittest .mock import PropertyMock
1921 from unittest .mock import patch
2022
2123try :
@@ -70,7 +72,7 @@ def test_load_arduino_cli_valid(self, mock_popen):
7072 ServerCompilerSettings ().load_ide_option = 'open'
7173 with patch (
7274 'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir' ,
73- new_callable = mock . PropertyMock ) as mock_compiler_dir :
75+ new_callable = PropertyMock ) as mock_compiler_dir :
7476 mock_compiler_dir .return_value = 'true' # do nothing command
7577 expected_command = ['true' , sketch_path ]
7678 success , conclusion , out , error , exit_code = \
@@ -81,7 +83,7 @@ def test_load_arduino_cli_valid(self, mock_popen):
8183 ServerCompilerSettings ().load_ide_option = 'verify'
8284 with patch (
8385 'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir' ,
84- new_callable = mock . PropertyMock ) as mock_compiler_dir :
86+ new_callable = PropertyMock ) as mock_compiler_dir :
8587 mock_compiler_dir .return_value = 'true' # do nothing command
8688 mock_popen .return_value .communicate .return_value = ('test' , 'test' )
8789 mock_popen .return_value .returncode = 0
@@ -95,7 +97,7 @@ def test_load_arduino_cli_valid(self, mock_popen):
9597 ServerCompilerSettings ().load_ide_option = 'upload'
9698 with patch (
9799 'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir' ,
98- new_callable = mock . PropertyMock ) as mock_compiler_dir :
100+ new_callable = PropertyMock ) as mock_compiler_dir :
99101 mock_compiler_dir .return_value = 'true' # do nothing command
100102 mock_popen .return_value .communicate .return_value = ('test' , 'test' )
101103 mock_popen .return_value .returncode = 0
@@ -113,7 +115,7 @@ def test_load_arduino_cli_valid(self, mock_popen):
113115 ServerCompilerSettings ().load_ide_option = 'upload'
114116 with patch (
115117 'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir' ,
116- new_callable = mock . PropertyMock ) as mock_compiler_dir :
118+ new_callable = PropertyMock ) as mock_compiler_dir :
117119 mock_compiler_dir .return_value = 'いろはにほへとちり' # unicode
118120 mock_popen .return_value .communicate .return_value = (
119121 'Γαζέες καὶ μυρτιὲς' , 'Âne ex aéquo au whist' )
@@ -139,29 +141,28 @@ def test_load_arduino_cli_invalid(self):
139141 self .delete_default_settings_file ()
140142 success , conclusion , out , error , exit_code = actions .load_arduino_cli ()
141143 self .assertFalse (success )
142- self .assertEqual (conclusion , 'Unable to find Arduino IDE ' )
144+ self .assertEqual (conclusion , 'arduinoOpErrorIdeDirTitle ' )
143145
144146 # Test for error if compiler dir is not set
145147 with patch (
146148 'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir' ,
147- new_callable = mock . PropertyMock ) as mock_compiler_dir :
149+ new_callable = PropertyMock ) as mock_compiler_dir :
148150 with patch (
149151 'ardublocklyserver.actions.ServerCompilerSettings.'
150- 'load_ide_option' , new_callable = mock . PropertyMock ) as \
152+ 'load_ide_option' , new_callable = PropertyMock ) as \
151153 mock_load_ide_option :
152154 mock_compiler_dir .return_value = 'true' # do nothing command
153155 mock_load_ide_option .return_value = None
154156 success , conclusion , out , error , exit_code = \
155157 actions .load_arduino_cli ()
156158 self .assertFalse (success )
157- self .assertEqual (conclusion ,
158- 'What should we do with the Sketch?' )
159+ self .assertEqual (conclusion , 'arduinoOpErrorIdeOptionTitle' )
159160
160161 # Test for error if serial port unset, only required when set to upload
161162 ServerCompilerSettings ().load_ide_option = 'upload'
162163 with patch (
163164 'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir' ,
164- new_callable = mock . PropertyMock ) as mock_compiler_dir :
165+ new_callable = PropertyMock ) as mock_compiler_dir :
165166 with patch (
166167 'ardublocklyserver.actions.ServerCompilerSettings.'
167168 'get_serial_port_flag' ) as mock_get_serial_port_flag :
@@ -170,13 +171,13 @@ def test_load_arduino_cli_invalid(self):
170171 success , conclusion , out , error , exit_code = \
171172 actions .load_arduino_cli ()
172173 self .assertFalse (success )
173- self .assertEqual (conclusion , 'Serial Port unavailable ' )
174+ self .assertEqual (conclusion , 'arduinoOpErrorIdePortTitle ' )
174175
175176 # Test for error if board type unset, only required when set to upload
176177 ServerCompilerSettings ().load_ide_option = 'upload'
177178 with patch (
178179 'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir' ,
179- new_callable = mock . PropertyMock ) as mock_compiler_dir :
180+ new_callable = PropertyMock ) as mock_compiler_dir :
180181 with patch (
181182 'ardublocklyserver.actions.ServerCompilerSettings.'
182183 'get_arduino_board_flag' ) as mock_get_arduino_board_flag :
@@ -185,7 +186,7 @@ def test_load_arduino_cli_invalid(self):
185186 success , conclusion , out , error , exit_code = \
186187 actions .load_arduino_cli ()
187188 self .assertFalse (success )
188- self .assertEqual (conclusion , 'Unknown Arduino Board ' )
189+ self .assertEqual (conclusion , 'arduinoOpErrorIdeBoardTitle ' )
189190
190191 #
191192 # Tests sketch creation
0 commit comments