Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
ea75a998
Commit
ea75a998
authored
Apr 26, 2017
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix server tests for actions.py
parent
0b8ce08d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
13 deletions
+22
-13
.appveyor.yml
.appveyor.yml
+2
-0
.travis.yml
.travis.yml
+2
-0
ardublocklyserver/tests/actions_test.py
ardublocklyserver/tests/actions_test.py
+14
-13
circle.yml
circle.yml
+4
-0
No files found.
.appveyor.yml
View file @
ea75a998
...
...
@@ -79,6 +79,8 @@ test_script:
-
cmd
:
"
%PYTHON3%
\\
python
ardublocklyserver
\\
tests
\\
sketchcreator_test.py"
-
cmd
:
"
%PYTHON%
\\
python
ardublocklyserver
\\
tests
\\
compilersettings_test.py"
-
cmd
:
"
%PYTHON3%
\\
python
ardublocklyserver
\\
tests
\\
compilersettings_test.py"
-
cmd
:
"
%PYTHON%
\\
python
ardublocklyserver
\\
tests
\\
actions_test.py"
-
cmd
:
"
%PYTHON3%
\\
python
ardublocklyserver
\\
tests
\\
actions_test.py"
# Push artefact to S3 bucket and list all
before_deploy
:
...
...
.travis.yml
View file @
ea75a998
...
...
@@ -74,6 +74,8 @@ script:
-
python3 ardublocklyserver/tests/sketchcreator_test.py
-
python ardublocklyserver/tests/compilersettings_test.py
-
python3 ardublocklyserver/tests/compilersettings_test.py
-
python ardublocklyserver/tests/actions_test.py
-
python3 ardublocklyserver/tests/actions_test.py
# Deploy the build version in an S3 bucket
deploy
:
...
...
ardublocklyserver/tests/actions_test.py
View file @
ea75a998
...
...
@@ -14,8 +14,10 @@ import unittest
try
:
import
mock
from
mock
import
patch
from
mock
import
PropertyMock
except
ImportError
:
from
unittest.mock
import
MagicMock
as
mock
from
unittest.mock
import
PropertyMock
from
unittest.mock
import
patch
try
:
...
...
@@ -70,7 +72,7 @@ class ActionsTestCase(unittest.TestCase):
ServerCompilerSettings
().
load_ide_option
=
'open'
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir'
,
new_callable
=
mock
.
PropertyMock
)
as
mock_compiler_dir
:
new_callable
=
PropertyMock
)
as
mock_compiler_dir
:
mock_compiler_dir
.
return_value
=
'true'
# do nothing command
expected_command
=
[
'true'
,
sketch_path
]
success
,
conclusion
,
out
,
error
,
exit_code
=
\
...
...
@@ -81,7 +83,7 @@ class ActionsTestCase(unittest.TestCase):
ServerCompilerSettings
().
load_ide_option
=
'verify'
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir'
,
new_callable
=
mock
.
PropertyMock
)
as
mock_compiler_dir
:
new_callable
=
PropertyMock
)
as
mock_compiler_dir
:
mock_compiler_dir
.
return_value
=
'true'
# do nothing command
mock_popen
.
return_value
.
communicate
.
return_value
=
(
'test'
,
'test'
)
mock_popen
.
return_value
.
returncode
=
0
...
...
@@ -95,7 +97,7 @@ class ActionsTestCase(unittest.TestCase):
ServerCompilerSettings
().
load_ide_option
=
'upload'
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir'
,
new_callable
=
mock
.
PropertyMock
)
as
mock_compiler_dir
:
new_callable
=
PropertyMock
)
as
mock_compiler_dir
:
mock_compiler_dir
.
return_value
=
'true'
# do nothing command
mock_popen
.
return_value
.
communicate
.
return_value
=
(
'test'
,
'test'
)
mock_popen
.
return_value
.
returncode
=
0
...
...
@@ -113,7 +115,7 @@ class ActionsTestCase(unittest.TestCase):
ServerCompilerSettings
().
load_ide_option
=
'upload'
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir'
,
new_callable
=
mock
.
PropertyMock
)
as
mock_compiler_dir
:
new_callable
=
PropertyMock
)
as
mock_compiler_dir
:
mock_compiler_dir
.
return_value
=
'いろはにほへとちり'
# unicode
mock_popen
.
return_value
.
communicate
.
return_value
=
(
'Γαζέες καὶ μυρτιὲς'
,
'Âne ex aéquo au whist'
)
...
...
@@ -139,29 +141,28 @@ class ActionsTestCase(unittest.TestCase):
self
.
delete_default_settings_file
()
success
,
conclusion
,
out
,
error
,
exit_code
=
actions
.
load_arduino_cli
()
self
.
assertFalse
(
success
)
self
.
assertEqual
(
conclusion
,
'
Unable to find Arduino IDE
'
)
self
.
assertEqual
(
conclusion
,
'
arduinoOpErrorIdeDirTitle
'
)
# Test for error if compiler dir is not set
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir'
,
new_callable
=
mock
.
PropertyMock
)
as
mock_compiler_dir
:
new_callable
=
PropertyMock
)
as
mock_compiler_dir
:
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.'
'load_ide_option'
,
new_callable
=
mock
.
PropertyMock
)
as
\
'load_ide_option'
,
new_callable
=
PropertyMock
)
as
\
mock_load_ide_option
:
mock_compiler_dir
.
return_value
=
'true'
# do nothing command
mock_load_ide_option
.
return_value
=
None
success
,
conclusion
,
out
,
error
,
exit_code
=
\
actions
.
load_arduino_cli
()
self
.
assertFalse
(
success
)
self
.
assertEqual
(
conclusion
,
'What should we do with the Sketch?'
)
self
.
assertEqual
(
conclusion
,
'arduinoOpErrorIdeOptionTitle'
)
# Test for error if serial port unset, only required when set to upload
ServerCompilerSettings
().
load_ide_option
=
'upload'
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir'
,
new_callable
=
mock
.
PropertyMock
)
as
mock_compiler_dir
:
new_callable
=
PropertyMock
)
as
mock_compiler_dir
:
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.'
'get_serial_port_flag'
)
as
mock_get_serial_port_flag
:
...
...
@@ -170,13 +171,13 @@ class ActionsTestCase(unittest.TestCase):
success
,
conclusion
,
out
,
error
,
exit_code
=
\
actions
.
load_arduino_cli
()
self
.
assertFalse
(
success
)
self
.
assertEqual
(
conclusion
,
'
Serial Port unavailab
le'
)
self
.
assertEqual
(
conclusion
,
'
arduinoOpErrorIdePortTit
le'
)
# Test for error if board type unset, only required when set to upload
ServerCompilerSettings
().
load_ide_option
=
'upload'
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.compiler_dir'
,
new_callable
=
mock
.
PropertyMock
)
as
mock_compiler_dir
:
new_callable
=
PropertyMock
)
as
mock_compiler_dir
:
with
patch
(
'ardublocklyserver.actions.ServerCompilerSettings.'
'get_arduino_board_flag'
)
as
mock_get_arduino_board_flag
:
...
...
@@ -185,7 +186,7 @@ class ActionsTestCase(unittest.TestCase):
success
,
conclusion
,
out
,
error
,
exit_code
=
\
actions
.
load_arduino_cli
()
self
.
assertFalse
(
success
)
self
.
assertEqual
(
conclusion
,
'
Unknown Arduino Board
'
)
self
.
assertEqual
(
conclusion
,
'
arduinoOpErrorIdeBoardTitle
'
)
#
# Tests sketch creation
...
...
circle.yml
View file @
ea75a998
...
...
@@ -29,6 +29,7 @@ dependencies:
# Install and check Python 2 and 3
-
sudo apt-get update
-
sudo apt-get install -y python-support
-
sudo apt-get install -y python-tk
-
sudo apt-get install -y python3-setuptools
-
sudo apt-get install -y python3-dev
-
sudo apt-get install -y python3-tk
...
...
@@ -45,6 +46,7 @@ dependencies:
# Python packages (built on Python 2, tests run both 2 and 3)
-
sudo pip2 install mock
-
sudo pip2 install
-
sudo pip2 install awscli
-
sudo pip3 install mkdocs
-
sudo pip3 install pyinstaller
...
...
@@ -76,6 +78,8 @@ test:
-
python3 ardublocklyserver/tests/sketchcreator_test.py
-
python ardublocklyserver/tests/compilersettings_test.py
-
python3 ardublocklyserver/tests/compilersettings_test.py
-
python ardublocklyserver/tests/actions_test.py
-
python3 ardublocklyserver/tests/actions_test.py
general
:
artifacts
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment