Commit 6da9eeea authored by carlosperate's avatar carlosperate

Updating state of unit tests.

Still a lot of work to do in this area, but at least the scope of work is more clear now.
parent d332588e
...@@ -276,7 +276,7 @@ def get_serial_ports(): ...@@ -276,7 +276,7 @@ def get_serial_ports():
# #
# Launch IDE settings # Load IDE settings
# #
def set_load_ide_only(new_value): def set_load_ide_only(new_value):
ServerCompilerSettings().load_ide_option = new_value ServerCompilerSettings().load_ide_option = new_value
......
...@@ -59,10 +59,10 @@ class ServerCompilerSettings(object): ...@@ -59,10 +59,10 @@ class ServerCompilerSettings(object):
'arduino:avr:diecimila:cpu=atmega168'} 'arduino:avr:diecimila:cpu=atmega168'}
# Class dictionary to contain the computer COM ports, dynamic content # Class dictionary to contain the computer COM ports, dynamic content
__serial_ports = {'port1': 'COM1'} __serial_ports = {'port0': 'COM1'}
# Class dictionary to define IDE load options, static content # Class dictionary to define IDE load options, static content
__ide_load_options = {'open': 'Open sketch in IDE ', __ide_load_options = {'open': 'Open sketch in IDE',
'verify': 'Verify sketch', 'verify': 'Verify sketch',
'upload': 'Compile and Upload sketch'} 'upload': 'Compile and Upload sketch'}
...@@ -392,7 +392,7 @@ class ServerCompilerSettings(object): ...@@ -392,7 +392,7 @@ class ServerCompilerSettings(object):
Checks available Serial Ports and populates the serial port dictionary. Checks available Serial Ports and populates the serial port dictionary.
If the new serial port is not in the dictionary or the dictionary is If the new serial port is not in the dictionary or the dictionary is
empty it prints an error in the console. empty it prints an error in the console.
:param new_port: the new port to set :param new_port_value: the new port to set
""" """
# Check if the settings file value is present in available ports list # Check if the settings file value is present in available ports list
set_default = True set_default = True
...@@ -457,7 +457,7 @@ class ServerCompilerSettings(object): ...@@ -457,7 +457,7 @@ class ServerCompilerSettings(object):
port_id += 1 port_id += 1
# #
# Load the IDE only accessors # Load the IDE accessors
# #
def get_load_ide(self): def get_load_ide(self):
return self.__load_ide_option return self.__load_ide_option
...@@ -617,34 +617,3 @@ class ServerCompilerSettings(object): ...@@ -617,34 +617,3 @@ class ServerCompilerSettings(object):
def delete_settings_file(self): def delete_settings_file(self):
if os.path.exists(self.__settings_path): if os.path.exists(self.__settings_path):
os.remove(self.__settings_path) os.remove(self.__settings_path)
def get_board_value_from_key(self, string_key):
"""
As the board types are stored in a dictionary, the key and value for
the selected board are stored independently in 2 strings. This method
gets the dictionary value from a given key.
:param string_key: String representing the board_types dictionary key
:return: A string representation of board_types dictionary value from
the key.
"""
string_value = None
for key in self.__arduino_types:
if string_key is key:
string_value = self.__arduino_types[key]
return string_value
def get_board_key_from_value(self, string_value):
"""
As the board types are stored in a dictionary, the key and value for
the selected board are stored independently in 2 strings. This method
gets the dictionary key from a given value.
:param string_value: String representing the board_types dictionary
value to be found.
:return: A string representation of board_types dictionary key for
the given value.
"""
string_key = None
for key in self.__arduino_types:
if string_value is self.__arduino_types[key]:
string_key = key
return string_key
This diff is collapsed.
...@@ -162,6 +162,66 @@ class ServerCompilerSettingsTestCase(unittest.TestCase): ...@@ -162,6 +162,66 @@ class ServerCompilerSettingsTestCase(unittest.TestCase):
'JavaApplicationStub') 'JavaApplicationStub')
self.assertEqual(final_dir, ServerCompilerSettings().compiler_dir) self.assertEqual(final_dir, ServerCompilerSettings().compiler_dir)
#
# Test the sketch name accessors
#
def test_sketch_name_valid_accesor(self):
#TODO: This test
pass
def test_sketch_name_invalid_accesor(self):
#TODO: This test
pass
#
# Test the sketch directory accessors
#
def test_sketch_dir_valid_accesor(self):
#TODO: This test
pass
def test_sketch_dir_invalid_accesor(self):
#TODO: This test
pass
#
# Test the Arduino boards accessors
#
def test_arduino_board_valid_accesor(self):
#TODO: This test
pass
def test_arduino_board_invalid_accesor(self):
#TODO: This test
pass
def test_get_arduino_board_flag(self):
#TODO: This test
pass
def test_get_arduino_board_types(self):
#TODO: This test
pass
#
# Test the serial port accessors
#
def test_serial_port_valid_accesor(self):
#TODO: This test
pass
def test_serial_port_invalid_accesor(self):
#TODO: This test
pass
def test_get_serial_port_flag(self):
#TODO: This test
pass
def test_get_serial_ports(self):
#TODO: This test
pass
# #
# Testing the launch_IDE_option accessors # Testing the launch_IDE_option accessors
# #
...@@ -202,7 +262,23 @@ class ServerCompilerSettingsTestCase(unittest.TestCase): ...@@ -202,7 +262,23 @@ class ServerCompilerSettingsTestCase(unittest.TestCase):
self.assertEqual(instance.load_ide_option, old_load_ide_option) self.assertEqual(instance.load_ide_option, old_load_ide_option)
# #
# Testing the settings file # Test the default values function
#
def test_set_default_settings(self):
#TODO: This test
pass
def test_new_settings_file_defaults(self):
"""
Tests that a newly created instance without an already existing settings
file contains the default settings.
:return:
"""
#TODO: This test
pass
#
# Testing the save and read settings file functionality
# #
def test_settings_file_creation(self): def test_settings_file_creation(self):
""" """
...@@ -214,7 +290,16 @@ class ServerCompilerSettingsTestCase(unittest.TestCase): ...@@ -214,7 +290,16 @@ class ServerCompilerSettingsTestCase(unittest.TestCase):
ServerCompilerSettings().save_settings() ServerCompilerSettings().save_settings()
self.assertTrue(os.path.exists(settings_file)) self.assertTrue(os.path.exists(settings_file))
def test_settings_file_read(self): def test_settings_file_deletion(self):
self.delete_default_settings_file()
settings_file = self.get_default_settings_file_dir()
self.assertFalse(os.path.exists(settings_file))
ServerCompilerSettings().save_settings()
self.assertTrue(os.path.exists(settings_file))
ServerCompilerSettings().delete_settings_file()
self.assertFalse(os.path.exists(settings_file))
def test_settings_file_simple_read(self):
""" """
Simple test that checks for no exceptions happening while creating Simple test that checks for no exceptions happening while creating
and loading the created file. and loading the created file.
...@@ -224,6 +309,22 @@ class ServerCompilerSettingsTestCase(unittest.TestCase): ...@@ -224,6 +309,22 @@ class ServerCompilerSettingsTestCase(unittest.TestCase):
ServerCompilerSettings().get_settings_file_data() ServerCompilerSettings().get_settings_file_data()
ServerCompilerSettings().save_settings() ServerCompilerSettings().save_settings()
def test_settings_file_read(self):
"""
Tests that the settings are saved into a file and read correctly.
Checks that all saved settings are retrieved.
"""
#TODO: This test
pass
def test_save_file_unicode(self):
#TODO: This test
pass
def test_read_file_unicode(self):
#TODO: This test
pass
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -23,7 +23,7 @@ except ImportError: ...@@ -23,7 +23,7 @@ except ImportError:
class GuiTestCase(unittest.TestCase): class GuiTestCase(unittest.TestCase):
""" """
Tests for gu i module Tests for gui module
""" """
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment