Repository: SebRut/pygrocy (python)

Issue:
Task without due date gives error
Add a check for due date before parsing

```
Traceback (most recent call last):
  File "/config/custom_components/grocy/__init__.py", line 268, in async_update_tasks
    ] = await self.hass.async_add_executor_job(self.client.tasks)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 591, in tasks
    raw_tasks = self._api_client.get_tasks()
  File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 649, in get_tasks
    return [TaskResponse(data) for data in parsed_json]
  File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 649, in <listcomp>
    return [TaskResponse(data) for data in parsed_json]
  File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 458, in __init__
    self.due_date = parse_date(parsed_json.get("due_date"))
  File "/usr/local/lib/python3.8/site-packages/pygrocy/utils.py", line 10, in parse_date
    return iso8601.parse_date(input_value)
  File "/usr/local/lib/python3.8/site-packages/iso8601/iso8601.py", line 195, in parse_date
    raise ParseError("Unable to parse date string %r" % datestring)
iso8601.iso8601.ParseError: Unable to parse date string ''
```

Pull request description:
Check for empty string in parse_date
## Description

Tasks returns an empty string if due date is not set, so we'll check for that.

**Related issue (if applicable):** fixes #119 

## Checklist
  - [ ] The code change is tested and works locally.
  - [ ] tests pass. **Your PR won't be merged unless tests pass**
  - [ ] There is no commented out code in this PR


Patch:
diff --git a/pygrocy/utils.py b/pygrocy/utils.py
index 02fa408..2c11289 100644
--- a/pygrocy/utils.py
+++ b/pygrocy/utils.py
@@ -5,7 +5,7 @@ from datetime import datetime
 
 
 def parse_date(input_value):
-    if input_value is None:
+    if input_value is "" or input_value is None:
         return None
     return iso8601.parse_date(input_value)
 


Test patch:
diff --git a/test/test_utils.py b/test/test_utils.py
index 2d3409b..70d758a 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -16,7 +16,13 @@ class TestUtils(TestCase):
         date_obj = utils.parse_date(date_str)
 
         assert date_obj is None
+        
+    def test_parse_date_empty_string(self):
+        date_str = ""
+        date_obj = utils.parse_date(date_str)
 
+        assert date_obj is None
+       
     def test_parse_int_valid(self):
         int_str = "2"
         int_number = utils.parse_int(int_str)