Repository: Duke-GCB/DukeDSClient

Issue:
Fix error when the .ddsclient config file is empty
When a the .ddsclient config file is empty the following error is produced when running a command such as `ddsclient list`:
```
type object argument after ** must be a mapping, not NoneType
```
See #315 for more

Discussion:

Patch:
diff --git a/ddsc/config.py b/ddsc/config.py
index f74ab5d..582c9aa 100644
--- a/ddsc/config.py
+++ b/ddsc/config.py
@@ -88,7 +88,11 @@ class Config(object):
         filename = os.path.expanduser(filename)
         if os.path.exists(filename):
             with open(filename, 'r') as yaml_file:
-                self.update_properties(yaml.safe_load(yaml_file))
+                config_data = yaml.safe_load(yaml_file)
+                if config_data:
+                    self.update_properties(config_data)
+                else:
+                    raise ValueError("Error: Empty config file {}".format(filename))
 
     def update_properties(self, new_values):
         """


Test patch:
diff --git a/ddsc/tests/test_config.py b/ddsc/tests/test_config.py
index 58e21ad..073ad89 100644
--- a/ddsc/tests/test_config.py
+++ b/ddsc/tests/test_config.py
@@ -2,7 +2,7 @@ from unittest import TestCase
 import math
 import ddsc.config
 import multiprocessing
-from mock.mock import patch
+from mock.mock import patch, mock_open
 
 
 class TestConfig(TestCase):
@@ -159,3 +159,13 @@ class TestConfig(TestCase):
         }
         config.update_properties(some_config)
         self.assertEqual(config.storage_provider_id, '123456')
+
+    @patch('ddsc.config.os')
+    def test_add_properties_empty_file(self, mock_os):
+        mock_os.path.expanduser.return_value = '/home/user/.ddsclient'
+        mock_os.path.exists.return_value = True
+        config = ddsc.config.Config()
+        with self.assertRaises(ValueError) as raised_exception:
+            with patch('builtins.open', mock_open(read_data='')):
+                config.add_properties('~/.ddsclient')
+        self.assertEqual(str(raised_exception.exception), 'Error: Empty config file /home/user/.ddsclient')