Skip to content

Commit efee5d9

Browse files
committed
Server: Update unit test following server refactoring
1 parent 734267f commit efee5d9

File tree

6 files changed

+760
-238
lines changed

6 files changed

+760
-238
lines changed

.coveragerc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[run]
2+
branch = False
3+
cover_pylib = False
4+
source = ardublocklyserver/
5+
omit =
6+
ardublocklyserver/tests/*
7+
ardublocklyserver/local-packages/*
8+
ardublocklyserver/pyserialports/*
9+
10+
[report]
11+
show_missing = True
12+
skip_covered = False
13+
exclude_lines =
14+
# Don't complain if non-runnable code isn't run:
15+
if 0:
16+
if __name__ == .__main__.:

ardublocklyserver/actions.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def load_arduino_cli(sketch_path):
5353
parameter.
5454
5555
:param sketch_path: Path to the sketch to load into the Arduino IDE.
56-
:return: A tuple with the following data (success, conclusion, out, error,
57-
exit_code)
56+
:return: A tuple with the following data (success, ide_mode, std_out,
57+
err_out, exit_code)
5858
"""
5959
success = True
6060
ide_mode = 'unknown'
@@ -79,15 +79,17 @@ def load_arduino_cli(sketch_path):
7979
success = False
8080
exit_code = 54
8181
err_out = 'Launch IDE option not configured in the Settings.'
82-
elif settings.load_ide_option == 'upload':
83-
if not settings.get_serial_port_flag():
84-
success = False
85-
exit_code = 55
86-
err_out = 'Serial Port configured in Settings not accessible.'
87-
if not settings.get_arduino_board_flag():
88-
success = False
89-
exit_code = 56
90-
err_out = 'Arduino Board not configured in the Settings.'
82+
elif not settings.get_arduino_board_flag() and (
83+
settings.load_ide_option == 'upload' or
84+
settings.load_ide_option == 'verify'):
85+
success = False
86+
exit_code = 56
87+
err_out = 'Arduino Board not configured in the Settings.'
88+
elif not settings.get_serial_port_flag() and \
89+
settings.load_ide_option == 'upload':
90+
success = False
91+
exit_code = 55
92+
err_out = 'Serial Port configured in Settings not accessible.'
9193

9294
if success:
9395
ide_mode = settings.load_ide_option

ardublocklyserver/sketchcreator.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# -*- coding: utf-8 -*-
2-
#
3-
# Sketch Creator module creates an Arduino Sketch source code file.
4-
#
5-
# Copyright (c) 2017 carlosperate https://github.com/carlosperate/
6-
# Licensed under the Apache License, Version 2.0 (the "License"):
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
2+
"""Sketch Creator module creates an Arduino Sketch source code file.
3+
4+
Copyright (c) 2017 carlosperate https://github.com/carlosperate/
5+
Licensed under the Apache License, Version 2.0 (the "License"):
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
"""
98
from __future__ import unicode_literals, absolute_import, print_function
109
import codecs
1110
import os
@@ -72,7 +71,7 @@ def build_sketch_path(sketch_dir, sketch_name):
7271
if os.path.isdir(sketch_dir):
7372
try:
7473
sketch_path = os.path.join(sketch_dir, sketch_name)
75-
except TypeError as e:
74+
except (TypeError, AttributeError) as e:
7675
print('Error: %s\nSketch Name could not be processed.' % e)
7776
else:
7877
if not os.path.exists(sketch_path):

0 commit comments

Comments
 (0)