Autotest: Minor refactor for complete_failures.py

Separate the storing logic from the reporting logic.

BUG=None
DEPLOY=None
TEST=Unittests plus ran script.

Change-Id: I4a5265c03bcbf3c0fcee5abafcfb34308bf283ff
Reviewed-on: https://gerrit.chromium.org/gerrit/60697
Reviewed-by: Dennis Jeffrey <dennisjeffrey@chromium.org>
Tested-by: Keyar Hood <keyar@chromium.org>
Commit-Queue: Keyar Hood <keyar@chromium.org>
diff --git a/frontend/health/complete_failures.py b/frontend/health/complete_failures.py
index 8c78461..6688e8f 100644
--- a/frontend/health/complete_failures.py
+++ b/frontend/health/complete_failures.py
@@ -128,12 +128,10 @@
     return dict(always_failed.items() + running_passes.items())
 
 
-def email_about_test_failure(tests, storage):
+def store_results(tests, storage):
     """
-    Send emails based on the last time tests has passed.
+    Store information about tests that have been failing for a long time.
 
-    This involves updating the storage and sending an email if a test has
-    failed for a long time.
 
     @param tests: The test_name:time_of_last_pass pairs.
     @param storage: The storage object.
@@ -152,6 +150,14 @@
             except KeyError:
                 pass
 
+
+def email_about_test_failure(storage):
+    """
+    Send an email about all the tests in the storage object if there are any.
+
+    @param storage: The storage object.
+
+    """
     if storage:
         mail.send(_MAIL_RESULTS_FROM,
                   [_MAIL_RESULTS_TO],
@@ -172,7 +178,8 @@
     """
     storage = load_storage()
     tests = get_tests_to_analyze()
-    email_about_test_failure(tests, storage)
+    store_results(tests, storage)
+    email_about_test_failure(storage)
     save_storage(storage)
 
     return 0