From ec1d5e617ed2b47e625ebe166053665c7cd9d456 Mon Sep 17 00:00:00 2001
From: Paulus Schoutsen <paulus@paulusschoutsen.nl>
Date: Sat, 19 Sep 2015 12:29:23 -0700
Subject: [PATCH] Fix CI

---
 .gitignore                                          |  7 +++----
 homeassistant/components/automation/time.py         |  4 ++--
 .../frontend/www_static/home-assistant-polymer      |  2 +-
 homeassistant/components/logbook.py                 |  3 +++
 pytest.ini                                          |  2 ++
 script/cibuild                                      |  5 +++++
 script/lint                                         | 11 ++++++++++-
 script/test                                         | 13 +++++++++++--
 8 files changed, 37 insertions(+), 10 deletions(-)
 create mode 100644 pytest.ini

diff --git a/.gitignore b/.gitignore
index 881411c54ea..8935ffedc17 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,10 +15,6 @@ tests/config/home-assistant.log
 *.sublime-project
 *.sublime-workspace
 
-# Hide code validator output
-pep8.txt
-pylint.txt
-
 # Hide some OS X stuff
 .DS_Store
 .AppleDouble
@@ -30,6 +26,9 @@ Icon
 
 .idea
 
+# pytest
+.cache
+
 # GITHUB Proposed Python stuff:
 *.py[cod]
 
diff --git a/homeassistant/components/automation/time.py b/homeassistant/components/automation/time.py
index 559832eee80..1d97ccc135d 100644
--- a/homeassistant/components/automation/time.py
+++ b/homeassistant/components/automation/time.py
@@ -79,11 +79,11 @@ def if_action(hass, config):
         now = dt_util.now()
         if before is not None and now > now.replace(hour=before.hour,
                                                     minute=before.minute):
-                return False
+            return False
 
         if after is not None and now < now.replace(hour=after.hour,
                                                    minute=after.minute):
-                return False
+            return False
 
         if weekday is not None:
             now_weekday = WEEKDAYS[now.weekday()]
diff --git a/homeassistant/components/frontend/www_static/home-assistant-polymer b/homeassistant/components/frontend/www_static/home-assistant-polymer
index 63e039a221a..68f6c6ae5d3 160000
--- a/homeassistant/components/frontend/www_static/home-assistant-polymer
+++ b/homeassistant/components/frontend/www_static/home-assistant-polymer
@@ -1 +1 @@
-Subproject commit 63e039a221ae6771e0d7c6990d9a93b7cc22fc64
+Subproject commit 68f6c6ae5d37a1f0fcd1c36a8803581f9367ac5f
diff --git a/homeassistant/components/logbook.py b/homeassistant/components/logbook.py
index b653d0f76f2..3a2c1e137cb 100644
--- a/homeassistant/components/logbook.py
+++ b/homeassistant/components/logbook.py
@@ -134,6 +134,9 @@ def humanify(events):
             if event.event_type == EVENT_STATE_CHANGED:
                 entity_id = event.data['entity_id']
 
+                if entity_id is None:
+                    continue
+
                 if entity_id.startswith('sensor.'):
                     last_sensor_event[entity_id] = event
 
diff --git a/pytest.ini b/pytest.ini
new file mode 100644
index 00000000000..5ee64771657
--- /dev/null
+++ b/pytest.ini
@@ -0,0 +1,2 @@
+[pytest]
+testpaths = tests
diff --git a/script/cibuild b/script/cibuild
index ade1b1d91c5..b0e0a31fb89 100755
--- a/script/cibuild
+++ b/script/cibuild
@@ -4,4 +4,9 @@
 #                 designed to run on the continuous integration server.
 
 script/test coverage
+
+STATUS=$?
+
 coveralls
+
+exit $STATUS
diff --git a/script/lint b/script/lint
index 120f364120f..05178a20ad8 100755
--- a/script/lint
+++ b/script/lint
@@ -3,7 +3,16 @@
 cd "$(dirname "$0")/.."
 
 echo "Checking style with flake8..."
-flake8 homeassistant
+flake8 --exclude www_static homeassistant
+
+STATUS=$?
 
 echo "Checking style with pylint..."
 pylint homeassistant
+
+if [ $STATUS -eq 0 ]
+then
+  exit $?
+else
+  exit $STATUS
+fi
diff --git a/script/test b/script/test
index 56fe4dcec89..2e13bcc4b0e 100755
--- a/script/test
+++ b/script/test
@@ -7,10 +7,19 @@ cd "$(dirname "$0")/.."
 
 script/lint
 
+STATUS=$?
+
 echo "Running tests..."
 
 if [ "$1" = "coverage" ]; then
-  py.test --cov homeassistant tests
+  py.test --cov --cov-report=
 else
-  py.test tests
+  py.test
+fi
+
+if [ $STATUS -eq 0 ]
+then
+  exit $?
+else
+  exit $STATUS
 fi