Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
awstats
Commits
add22d0cad76
Commit
76384679
authored
May 26, 2011
by
Arthur Lutz
Browse files
added test (wip)
parent
5fdeded5e213
Changes
1
Hide whitespace changes
Inline
Side-by-side
test/test_compress.py
0 → 100644
View file @
add22d0c
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
#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'
)
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'
,
count
=
random
.
choice
(
range
(
2000
)),
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
)
if
__name__
==
'__main__'
:
from
logilab.common.testlib
import
unittest_main
unittest_main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment