incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/2] git commit: [#5701] add tests; limit default view to 10 min & busy tasks
Date Mon, 11 Feb 2013 19:59:56 GMT
[#5701] add tests; limit default view to 10 min & busy tasks


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1c6e4820
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1c6e4820
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1c6e4820

Branch: refs/heads/master
Commit: 1c6e4820058bb6a7b91c4678eaa872ec6104d25a
Parents: a840819
Author: Dave Brondsema <dbrondsema@geek.net>
Authored: Mon Feb 11 19:49:44 2013 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Mon Feb 11 19:59:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py           |   18 ++++++++------
 Allura/allura/templates/site_admin.html           |    2 +-
 Allura/allura/templates/site_admin_task_list.html |    2 +-
 Allura/allura/templates/site_admin_task_view.html |    4 +-
 Allura/allura/tests/functional/test_site_admin.py |   19 +++++++++++++--
 5 files changed, 30 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c6e4820/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index b0d0cd5..63e247e 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -250,21 +250,23 @@ class TaskManagerController(object):
 
     @expose('jinja:allura:templates/site_admin_task_list.html')
     @without_trailing_slash
-    def index(self, page_num=1, hours=1, state=None, task_name=None, host=None):
+    def index(self, page_num=1, minutes=10, state=None, task_name=None, host=None):
         now = datetime.utcnow()
         try:
             page_num = int(page_num)
         except ValueError as e:
             page_num = 1
         try:
-            hours = int(hours)
+            minutes = int(minutes)
         except ValueError as e:
-            hours = 1
-        start_dt = now - timedelta(hours=(page_num-1)*hours)
-        end_dt = now - timedelta(hours=page_num*hours)
+            minutes = 1
+        start_dt = now - timedelta(minutes=(page_num-1)*minutes)
+        end_dt = now - timedelta(minutes=page_num*minutes)
         start = bson.ObjectId.from_datetime(start_dt)
         end = bson.ObjectId.from_datetime(end_dt)
-        query = {'_id': {'$lt': start, '$gt': end}}
+        query = {'_id': {'$gt': end}}
+        if page_num > 1:
+            query['_id']['$lt'] = start
         if state:
             query['state'] = state
         if task_name:
@@ -281,7 +283,7 @@ class TaskManagerController(object):
         return dict(
                 tasks=tasks,
                 page_num=page_num,
-                hours=hours,
+                minutes=minutes,
                 newer_url=newer_url,
                 older_url=older_url,
                 window_start=start_dt,
@@ -293,7 +295,7 @@ class TaskManagerController(object):
     def view(self, task_id):
         try:
             task = M.monq_model.MonQTask.query.get(_id=bson.ObjectId(task_id))
-        except bson.InvalidId as e:
+        except bson.errors.InvalidId as e:
             task = None
         if task:
             task.project = M.Project.query.get(_id=task.context.project_id)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c6e4820/Allura/allura/templates/site_admin.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin.html b/Allura/allura/templates/site_admin.html
index d15daf1..b8b1b7d 100644
--- a/Allura/allura/templates/site_admin.html
+++ b/Allura/allura/templates/site_admin.html
@@ -21,7 +21,7 @@
     <li class="{{page=='add_subscribers' and 'active' or ''}}"><a href="{{sidebar_rel}}add_subscribers"><b
data-icon="{{g.icons['admin'].char}}" class="ico {{g.icons['admin'].css}}"></b>Add
Subscribers</a></li>
     <li class="{{page=='new_projects' and 'active' or ''}}"><a href="{{sidebar_rel}}new_projects"><b
data-icon="{{g.icons['admin'].char}}" class="ico {{g.icons['admin'].css}}"></b>New
Projects</a></li>
     <li class="{{page=='reclone_repo' and 'active' or ''}}"><a href="{{sidebar_rel}}reclone_repo"><b
data-icon="{{g.icons['admin'].char}}" class="ico {{g.icons['admin'].css}}"></b>Reclone
Repo</a></li>
-    <li class="{{page=='task_manager' and 'active' or ''}}"><a href="{{sidebar_rel}}task_manager"><b
data-icon="{{g.icons['stats'].char}}" class="ico {{g.icons['stats'].css}}"></b>Task
Manager</a></li>
+    <li class="{{page=='task_manager' and 'active' or ''}}"><a href="{{sidebar_rel}}task_manager?state=busy"><b
data-icon="{{g.icons['stats'].char}}" class="ico {{g.icons['stats'].css}}"></b>Task
Manager</a></li>
 
   </ul>
 </div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c6e4820/Allura/allura/templates/site_admin_task_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_task_list.html b/Allura/allura/templates/site_admin_task_list.html
index 20dc2d7..5862a9a 100644
--- a/Allura/allura/templates/site_admin_task_list.html
+++ b/Allura/allura/templates/site_admin_task_list.html
@@ -51,7 +51,7 @@
     <label>Host:</label> <input name="host" value="{{ request.params.host
}}" />
     <input type="submit" />
     <input type="hidden" name="page_num" value="{{ page_num }}" />
-    <input type="hidden" name="hours" value="{{ hours }}" />
+    <input type="hidden" name="minutes" value="{{ minutes }}" />
 </form>
 {{ _paging() }}
 <div class="paging-window">

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c6e4820/Allura/allura/templates/site_admin_task_view.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_task_view.html b/Allura/allura/templates/site_admin_task_view.html
index 2b1abee..ef5a524 100644
--- a/Allura/allura/templates/site_admin_task_view.html
+++ b/Allura/allura/templates/site_admin_task_view.html
@@ -129,11 +129,11 @@
         {% for i in indexes %}
         <tr>
             <td class="first-column-headers"></td>
-            <td>{{ (task.args[i] or '')|truncate }}</td>
+            <td>{{ task.args[i] }}</td>
             <td class="spacer"></td>
             {% if kwargs[i] %}
             <th class="second-column-headers side-header">{{ kwargs[i][0] }}</th>
-            <td>{{ (kwargs[i][1] or '')|truncate }}</td>
+            <td>{{ kwargs[i][1] }}</td>
             {% else %}
             <td class="second-column-headers"></td>
             <td></td>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c6e4820/Allura/allura/tests/functional/test_site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index 6f1a3f1..6483b0f 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -1,7 +1,5 @@
-import os, allura
-
+from allura import model as M
 from allura.tests import TestController
-from nose.tools import assert_equal
 
 
 class TestSiteAdmin(TestController):
@@ -74,3 +72,18 @@ class TestSiteAdmin(TestController):
     def test_reclone_repo_default_value(self):
         r = self.app.get('/nf/admin/reclone_repo')
         assert 'value="p"' in r
+
+    def test_task_list(self):
+        r = self.app.get('/nf/admin/task_manager', extra_environ=dict(username='*anonymous'),
status=302)
+        import math
+        task = M.MonQTask.post(math.ceil, (12.5,))
+        r = self.app.get('/nf/admin/task_manager?page_num=1')
+        assert 'math.ceil' in r, r
+
+    def test_task_view(self):
+        import math
+        task = M.MonQTask.post(math.ceil, (12.5,))
+        url = '/nf/admin/task_manager/view/%s' % task._id
+        r = self.app.get(url, extra_environ=dict(username='*anonymous'), status=302)
+        r = self.app.get(url)
+        assert 'math.ceil' in r, r


Mime
View raw message