Initial implementation of Test Planner Test View.

Trying again because generated patch was malformed.

Signed-off-by: James Ren <jamesren@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@4556 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/planner/models.py b/frontend/planner/models.py
index 9334a09..76aa4a2 100644
--- a/frontend/planner/models.py
+++ b/frontend/planner/models.py
@@ -5,7 +5,7 @@
 from autotest_lib.frontend.afe import model_logic, rpc_utils
 from autotest_lib.frontend.tko import models as tko_models
 from autotest_lib.frontend.planner import model_attributes
-from autotest_lib.client.common_lib import utils
+from autotest_lib.client.common_lib import utils, host_queue_entry_states
 
 
 class Plan(dbmodels.Model, model_logic.ModelExtensions):
@@ -174,6 +174,29 @@
         db_table = 'planner_test_jobs'
 
 
+    def active(self):
+        for hqe in self.afe_job.hostqueueentry_set.all():
+            if not hqe.complete:
+                return True
+        return False
+
+
+    def all_tests_passed(self):
+        if self.active():
+            return False
+
+        Status = host_queue_entry_states.Status
+        if self.afe_job.hostqueueentry_set.exclude(status=Status.COMPLETED):
+            return False
+
+        tko_tests = tko_models.Test.objects.filter(
+                job__afe_job_id=self.afe_job.id)
+        for tko_test in tko_tests:
+            if tko_test.status.word != 'GOOD':
+                return False
+        return True
+
+
     def _get_details_unicode(self):
         return 'AFE job %s' % self.afe_job.id