Commit c29ce872 authored by carlosperate's avatar carlosperate

Set Arduino sketch default location file to be project directory.

This helps circumvent the issue with the default being the OS root in OSX, which needs sudo rights to write a file.
parent 065dfe9b
......@@ -241,8 +241,8 @@ class ServerCompilerSettings(object):
sketch_dir = property(get_sketch_dir, set_sketch_dir)
def set_sketch_dir_default(self):
""" Sketch default location is the current working directory. """
self.__sketch_dir = os.getcwd()
""" Sketch default location the same as the settings file location. """
self.__sketch_dir = os.path.dirname(self.__settings_path)
def set_sketch_dir_from_file(self, new_sketch_dir):
""" The sketch directory must be a folder """
......
......@@ -88,7 +88,7 @@ class ServerCompilerSettingsTestCase(unittest.TestCase):
mock_os_path_isfile.return_value = True
old_compiler_dir = instance.compiler_dir
self.assertIsNone(old_compiler_dir)
new_compiler_dir = os.path.join(os.getcwd(), 'random.exe')
new_compiler_dir = os.path.join(os.getcwd(), 'ろΓαζςÂaé', 'random.exe')
instance.compiler_dir = new_compiler_dir
self.assertEqual(
instance.compiler_dir,
......@@ -165,13 +165,27 @@ class ServerCompilerSettingsTestCase(unittest.TestCase):
#
# Test the sketch name accessors
#
def test_sketch_name_valid_accesor(self):
#TODO: This test
pass
@mock.patch('ardublocklyserver.compilersettings.os.path.isdir')
def test_sketch_name_valid_accesor(self, mock_isdir):
self.delete_default_settings_file()
old_sketch_dir = ServerCompilerSettings().sketch_dir
mock_isdir.return_value = True
test_sketch_dir = os.path.join(os.getcwd(), 'unicode_いろΓαζέεςÂaéquo')
ServerCompilerSettings().sketch_dir = test_sketch_dir
self.assertEqual(test_sketch_dir, ServerCompilerSettings().sketch_dir)
self.assertNotEqual(old_sketch_dir, ServerCompilerSettings().sketch_dir)
def test_sketch_name_invalid_accesor(self):
#TODO: This test
pass
"""
Tests path doesn't get saved the input is not a valid directory.
"""
self.delete_default_settings_file()
old_sketch_dir = ServerCompilerSettings().sketch_dir
test_sketch_dir = os.path.join(os.getcwd(), 'random_faKe_dir_ろ')
ServerCompilerSettings().sketch_dir = test_sketch_dir
self.assertNotEqual(test_sketch_dir,
ServerCompilerSettings().sketch_dir)
self.assertEqual(old_sketch_dir, ServerCompilerSettings().sketch_dir)
#
# Test the sketch directory accessors
......
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