Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 94BF6C785 for ; Tue, 10 Sep 2013 16:17:22 +0000 (UTC) Received: (qmail 3867 invoked by uid 500); 10 Sep 2013 16:17:22 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 3816 invoked by uid 500); 10 Sep 2013 16:17:22 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 3527 invoked by uid 99); 10 Sep 2013 16:17:22 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Sep 2013 16:17:22 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D844589F711; Tue, 10 Sep 2013 16:17:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: tvansteenburgh@apache.org To: allura-commits@incubator.apache.org Date: Tue, 10 Sep 2013 16:17:31 -0000 Message-Id: In-Reply-To: <97de84792540410994e614b71927f1dd@git.apache.org> References: <97de84792540410994e614b71927f1dd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/14] git commit: [#6545] tests [#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/master Commit: 021ee37fc6369d14c22be587bf5874362f38fb98 Parents: 88b3fad Author: Dave Brondsema Authored: Fri Sep 6 21:05:29 2013 +0000 Committer: Tim Van Steenburgh 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'' 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], + ] + })