Commit 7038735e authored by Arthur Lutz's avatar Arthur Lutz

[pkginfo] prepare 0.1.3

* fix schema for tests
parent 538fa2723431
......@@ -4,7 +4,7 @@
modname = 'awstats'
distname = 'cubicweb-awstats'
numversion = (0, 1, 2)
numversion = (0, 1, 3)
version = '.'.join(str(num) for num in numversion)
license = 'LGPL'
......
cubicweb-awstats (0.1.0-1) unstable; urgency=low
cubicweb-awstats (0.1.3-1) unstable; urgency=low
* initial release
--
-- Julien Jehannet <julien.jehannet@logilab.fr> Tue, 04 Oct 2011 10:36:10 +0200
Source: cubicweb-awstats
Section: web
Priority: optional
Maintainer: LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>
Maintainer: Logilab S.A. <contact@logilab.fr>
Uploaders: Julien Jehannet <julien.jehannet@logilab.fr>
Build-Depends: debhelper (>= 5.0.37.1), python (>=2.4), python-dev (>=2.4)
Standards-Version: 3.8.0
Homepage: http://www.cubicweb.org/project/awstats
Package: cubicweb-awstats
......
File mode changed from 100644 to 100755
#!/usr/bin/env python
# pylint: disable=W0142,W0403,W0404,W0613,W0622,W0622,W0704,R0904,C0103,E0611
#
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb tag cube.
......
from yams.buildobjs import EntityType, RelationDefinition, String
class Content(EntityType):
title = String()
class stats_about(RelationDefinition):
subject = 'Hits'
object = 'Content'
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......
from collections import defaultdict
from datetime import datetime, timedelta
import random
from cubicweb.devtools.testlib import CubicWebTC
from logilab.common import date
from datetime import datetime, timedelta
import random
from cubes.awstats.utils import compress_old_hits
from utils import compress_old_hits
#TODO fake schema addition with stats_about
class CompressTest(CubicWebTC):
# def setUp(self):
# super(CompressTest, self).setUp()
# self.schema.add_entity_type(EntityType('Content'))
# self.schema.add_relation_type(RelationType('stats_about'))
# self.schema.add_relation_def(RelationDefinition('Hits', 'stats_about', 'Content'))
def test_compress(self):
req = self.request()
content = req.create_entity('TestContent', title=u'test')
update_stats=defaultdict(int)
content = req.create_entity('Content', title=u'test')
for day in date.date_range(datetime.now()-timedelta(200), datetime.now()):
stp = req.create_entity('StatPeriod', start=day, stop=day+timedelta(1))
hit = req.create_entity('Hits', hit_type=u'normal',
......@@ -26,9 +21,10 @@ class CompressTest(CubicWebTC):
period=stp, stats_about=content)
self.assertEqual(len(req.execute('Any X WHERE X is Hits')), 200)
self.assertEqual(len(req.execute('Any P WHERE P is StatPeriod, P start S, P stop E HAVING E-S >= 27')), 0)
compress(req)
#SQLITE bug self.assertEqual(len(req.execute('Any P WHERE P is StatPeriod, P start S, P stop E HAVING E-S >= 27')), 9)
self.assertNotEquals(len(req.execute('Any X WHERE X is Hits')), 200)
compress_old_hits(req, update_stats)
# XXX SQLite bug ?
# self.assertEqual(len(req.execute('Any P WHERE P is StatPeriod, P start S, P stop E HAVING E-S >= 27')), 9)
self.assertNotEqual(len(req.execute('Any X WHERE X is Hits')), 200)
if __name__ == '__main__':
......
../utils.py
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment