Skip to content

Commit ea75a99

Browse files
committed
Fix server tests for actions.py
1 parent 0b8ce08 commit ea75a99

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

.appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ test_script:
7979
- cmd: "%PYTHON3%\\python ardublocklyserver\\tests\\sketchcreator_test.py"
8080
- cmd: "%PYTHON%\\python ardublocklyserver\\tests\\compilersettings_test.py"
8181
- cmd: "%PYTHON3%\\python ardublocklyserver\\tests\\compilersettings_test.py"
82+
- cmd: "%PYTHON%\\python ardublocklyserver\\tests\\actions_test.py"
83+
- cmd: "%PYTHON3%\\python ardublocklyserver\\tests\\actions_test.py"
8284

8385
# Push artefact to S3 bucket and list all
8486
before_deploy:

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ script:
7474
- python3 ardublocklyserver/tests/sketchcreator_test.py
7575
- python ardublocklyserver/tests/compilersettings_test.py
7676
- python3 ardublocklyserver/tests/compilersettings_test.py
77+
- python ardublocklyserver/tests/actions_test.py
78+
- python3 ardublocklyserver/tests/actions_test.py
7779

7880
# Deploy the build version in an S3 bucket
7981
deploy:

ardublocklyserver/tests/actions_test.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
try:
1515
import mock
1616
from mock import patch
17+
from mock import PropertyMock
1718
except ImportError:
1819
from unittest.mock import MagicMock as mock
20+
from unittest.mock import PropertyMock
1921
from unittest.mock import patch
2022

2123
try:
@@ -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

circle.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies:
2929
# Install and check Python 2 and 3
3030
- sudo apt-get update
3131
- sudo apt-get install -y python-support
32+
- sudo apt-get install -y python-tk
3233
- sudo apt-get install -y python3-setuptools
3334
- sudo apt-get install -y python3-dev
3435
- sudo apt-get install -y python3-tk
@@ -45,6 +46,7 @@ dependencies:
4546

4647
# Python packages (built on Python 2, tests run both 2 and 3)
4748
- sudo pip2 install mock
49+
- sudo pip2 install
4850
- sudo pip2 install awscli
4951
- sudo pip3 install mkdocs
5052
- sudo pip3 install pyinstaller
@@ -76,6 +78,8 @@ test:
7678
- python3 ardublocklyserver/tests/sketchcreator_test.py
7779
- python ardublocklyserver/tests/compilersettings_test.py
7880
- python3 ardublocklyserver/tests/compilersettings_test.py
81+
- python ardublocklyserver/tests/actions_test.py
82+
- python3 ardublocklyserver/tests/actions_test.py
7983

8084
general:
8185
artifacts:

0 commit comments

Comments
 (0)