From 0f3773377750f10396a95e09699f21a9f440205c Mon Sep 17 00:00:00 2001
From: Daniel Brown <ddb@star.sr.bham.ac.uk>
Date: Wed, 31 Jul 2013 16:04:14 +0100
Subject: [PATCH] more interface updates, remove purposefuly added exception

---
 pykat/testing/test.py                         |  1 -
 pykat/testing/web/database_indices.py         | 18 +++++++++++++++++-
 pykat/testing/web/templates/finesse_test.html |  1 +
 pykat/testing/web/web_interface.py            | 10 ++++++----
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/pykat/testing/test.py b/pykat/testing/test.py
index 6439f3d..851331d 100644
--- a/pykat/testing/test.py
+++ b/pykat/testing/test.py
@@ -387,7 +387,6 @@ class FinesseTestProcess(Thread):
     def run(self):
         
         try:
-            raise Exception("Test exception")
             self.startFinesseTest()
         except Exception as ex:
             
diff --git a/pykat/testing/web/database_indices.py b/pykat/testing/web/database_indices.py
index ad9c46f..943d5cf 100644
--- a/pykat/testing/web/database_indices.py
+++ b/pykat/testing/web/database_indices.py
@@ -1,5 +1,5 @@
 from CodernityDB.tree_index import TreeBasedIndex
-
+from CodernityDB.hash_index import HashIndex
 from hashlib import md5
 
 class TestIDIndex(TreeBasedIndex):
@@ -15,5 +15,21 @@ class TestIDIndex(TreeBasedIndex):
         else:
             return None
         
+    def make_key(self, key):
+        return key
+
+class SrcCommitIndex(HashIndex):
+
+    def __init__(self, *args, **kwargs):
+        kwargs['key_format'] = '40s'
+        super(TestIDIndex, self).__init__(*args, **kwargs)
+
+    def make_key_value(self, data):
+        if data['t'] == 'test':
+            key = int(data['git_commit'])
+            return key, None
+        else:
+            return None
+        
     def make_key(self, key):
         return key
\ No newline at end of file
diff --git a/pykat/testing/web/templates/finesse_test.html b/pykat/testing/web/templates/finesse_test.html
index 92fd4d2..3b9b540 100644
--- a/pykat/testing/web/templates/finesse_test.html
+++ b/pykat/testing/web/templates/finesse_test.html
@@ -148,6 +148,7 @@
                             "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                                 console.log(oData["test_id"]);
                                 var a = $('<input type="button" style="margin: 0" value="View report"></input>').click(function () {  
+                                            window.location = "/finesse/view/" + oData["test_id"] +  "/"
                                         });
     
                                 var b = $('<input type="button" style="margin: 0" value="Rerun test"></input>').click( function () {
diff --git a/pykat/testing/web/web_interface.py b/pykat/testing/web/web_interface.py
index 3b461f6..8c7ca08 100644
--- a/pykat/testing/web/web_interface.py
+++ b/pykat/testing/web/web_interface.py
@@ -15,8 +15,8 @@ from pykat.testing.web import app
 
 from CodernityDB.database_thread_safe import ThreadSafeDatabase
 from CodernityDB.database import RecordNotFound
-from hashlib import md5
-from pykat.testing.web.database_indices import TestIDIndex
+
+from pykat.testing.web.database_indices import TestIDIndex, SrcCommitIndex
 
 import os, sys
 
@@ -52,6 +52,7 @@ if db.exists():
 else:
     db.create()
     db.add_index(TestIDIndex(db.path, 'testid'))
+    db.add_index(SrcCommitIndex(db.path, 'src_commit'))
     
     
 print "loading web interface"
@@ -330,14 +331,15 @@ def finesse_get_log(count,branch):
     for e in log_entries:
         
         vals = e.split(" ",1)
+        vals[0] = vals[0].strip()
         
-        if len(vals[0]) > 8:
+        if len(vals[0]) == 40:
             if len(vals) > 1:
                 message = vals[1]
             else:
                 message = "[no commit message]"
             
-            log2send.append({'commit':vals[0][0:8], 'message':message})
+            log2send.append({'commit':vals[0], 'message':message})
             
     
     return jsonify(logs=log2send)
-- 
GitLab