Commit cb5c1e73 authored by Julien Cristau's avatar Julien Cristau
Browse files

[test] port to cubicweb 3.19

parent 65a4bd1c8161
...@@ -13,7 +13,7 @@ author_email = 'contact@logilab.fr' ...@@ -13,7 +13,7 @@ author_email = 'contact@logilab.fr'
description = 'cubicweb integrated awstats frontend' description = 'cubicweb integrated awstats frontend'
web = 'http://www.cubicweb.org/project/%s' % distname web = 'http://www.cubicweb.org/project/%s' % distname
__depends__ = {'cubicweb': '>= 3.15.0',} __depends__ = {'cubicweb': '>= 3.19.0',}
__recommends__ = {'cubicweb-raphael': None,} __recommends__ = {'cubicweb-raphael': None,}
classifiers = [ classifiers = [
......
...@@ -20,7 +20,7 @@ BuildArch: noarch ...@@ -20,7 +20,7 @@ BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildRequires: %{python} %{python}-setuptools BuildRequires: %{python} %{python}-setuptools
Requires: cubicweb >= 3.15.0 Requires: cubicweb >= 3.19.0
%description %description
awstats component for the CubicWeb framework awstats component for the CubicWeb framework
......
...@@ -10,7 +10,7 @@ Homepage: http://www.cubicweb.org/project/awstats ...@@ -10,7 +10,7 @@ Homepage: http://www.cubicweb.org/project/awstats
Package: cubicweb-awstats Package: cubicweb-awstats
Architecture: all Architecture: all
Depends: cubicweb-common (>= 3.15.0) Depends: cubicweb-common (>= 3.19.0)
Recommends: cubicweb-raphael Recommends: cubicweb-raphael
Description: cubicweb integrated awstats frontend Description: cubicweb integrated awstats frontend
CubicWeb is a semantic web application framework. CubicWeb is a semantic web application framework.
......
...@@ -11,20 +11,20 @@ from cubes.awstats.utils import compress_old_hits ...@@ -11,20 +11,20 @@ from cubes.awstats.utils import compress_old_hits
class CompressTest(CubicWebTC): class CompressTest(CubicWebTC):
def test_compress(self): def test_compress(self):
req = self.request() with self.admin_access.client_cnx() as cnx:
update_stats=defaultdict(int) update_stats=defaultdict(int)
content = req.create_entity('Content', title=u'test') content = cnx.create_entity('Content', title=u'test')
for day in date.date_range(datetime.now()-timedelta(200), datetime.now()): for day in date.date_range(datetime.now()-timedelta(200), datetime.now()):
stp = req.create_entity('StatPeriod', start=day, stop=day+timedelta(1)) stp = cnx.create_entity('StatPeriod', start=day, stop=day+timedelta(1))
hit = req.create_entity('Hits', hit_type=u'normal', hit = cnx.create_entity('Hits', hit_type=u'normal',
count=random.choice(range(2000)), count=random.choice(range(2000)),
period=stp, stats_about=content) period=stp, stats_about=content)
self.assertEqual(len(req.execute('Any X WHERE X is Hits')), 200) self.assertEqual(len(cnx.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) self.assertEqual(len(cnx.execute('Any P WHERE P is StatPeriod, P start S, P stop E HAVING E-S >= 27')), 0)
compress_old_hits(req, update_stats) compress_old_hits(cnx, update_stats)
# XXX SQLite bug ? # 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.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) self.assertNotEqual(len(cnx.execute('Any X WHERE X is Hits')), 200)
if __name__ == '__main__': if __name__ == '__main__':
......
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