incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [30/50] git commit: [#6545] tests
Date Tue, 17 Sep 2013 19:57:57 GMT
[#6545] tests


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

Branch: refs/heads/cj/6422
Commit: 021ee37fc6369d14c22be587bf5874362f38fb98
Parents: 88b3fad
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Sep 6 21:05:29 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Sep 10 14:36:31 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/test_helpers.py             |  7 +++-
 .../tests/functional/test_forum.py              | 43 ++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/021ee37f/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index e9bc8f9..d4e5a0c 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -19,8 +19,9 @@
 
 from unittest import TestCase
 from os import path
-from mock import Mock, patch
+from datetime import datetime
 
+from mock import Mock, patch
 from pylons import tmpl_context as c
 from nose.tools import eq_, assert_equals
 from IPython.testing.decorators import skipif, module_not_available
@@ -428,3 +429,7 @@ def test_absurl_no_request():
 def test_absurl_with_request():
     assert_equals(h.absurl('/p/test/foobar'), 'https://www.mysite.com/p/test/foobar')
 
+
+def test_daterange():
+    assert_equals(list(h.daterange(datetime(2013, 1, 1), datetime(2013, 1, 4))),
+                 [datetime(2013, 1, 1), datetime(2013, 1, 2), datetime(2013, 1, 3)])
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/021ee37f/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 12238c8..7980bee 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -762,3 +762,46 @@ class TestForum(TestController):
         assert u'téstforum'.encode('utf-8') in r
         r = self.app.get(u'/p/test/discussion/create_topic/téstforum/'.encode('utf-8'))
         assert u'<option value="téstforum" selected>Tést Forum</option>' in
r
+
+
+class TestForumStats(TestController):
+
+    def test_stats(self):
+        self.app.get('/discussion/stats', status=200)
+
+    @mock.patch('ming.session.Session.aggregate')  # mim doesn't support aggregate
+    def test_stats_data(self, aggregate):
+        # partial data, some days are implicit 0
+        aggregate.return_value = {'result': [
+            {"_id": {
+                "year": 2013,
+                "month": 1,
+                "day": 2},
+             "posts": 3
+            },
+            {"_id": {
+                "year": 2013,
+                "month": 1,
+                "day": 3},
+             "posts": 5
+            },
+            {"_id": {
+                "year": 2013,
+                "month": 1,
+                "day": 5},
+             "posts": 2
+            },
+        ]}
+        r = self.app.get('/discussion/stats_data?begin=2013-01-01&end=2013-01-06')
+        assert_equal(r.json, {
+            'begin': '2013-01-01 00:00:00',
+            'end': '2013-01-06 00:00:00',
+            'data': [
+                [1356998400000, 0],
+                [1357084800000, 3],
+                [1357171200000, 5],
+                [1357257600000, 0],
+                [1357344000000, 2],
+                [1357430400000, 0],
+            ]
+        })


Mime
View raw message