Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
09cea559
Commit
09cea559
authored
Aug 02, 2009
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unfutz naive timezon issues.
parent
fbf2f48c
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
233 additions
and
165 deletions
+233
-165
src/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
src/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
+157
-133
src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
...PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
+76
-32
No files found.
src/Products/PluginIndexes/DateIndex/tests/test_DateIndex.py
View file @
09cea559
This diff is collapsed.
Click to expand it.
src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
View file @
09cea559
...
@@ -16,14 +16,6 @@ $Id$
...
@@ -16,14 +16,6 @@ $Id$
"""
"""
import
unittest
import
unittest
import
Testing
import
Zope2
Zope2
.
startup
()
import
sys
from
Products.PluginIndexes.DateRangeIndex.DateRangeIndex
import
DateRangeIndex
class
Dummy
:
class
Dummy
:
...
@@ -74,11 +66,22 @@ def matchingDummies( value ):
...
@@ -74,11 +66,22 @@ def matchingDummies( value ):
class
DRI_Tests
(
unittest
.
TestCase
):
class
DRI_Tests
(
unittest
.
TestCase
):
def
setUp
(
self
):
pass
def
tearDown
(
self
):
def
_getTargetClass
(
self
):
pass
from
Products.PluginIndexes.DateRangeIndex.DateRangeIndex
\
import
DateRangeIndex
return
DateRangeIndex
def
_makeOne
(
self
,
id
,
since_field
=
None
,
until_field
=
None
,
caller
=
None
,
extra
=
None
,
):
klass
=
self
.
_getTargetClass
()
return
klass
(
id
,
since_field
,
until_field
,
caller
,
extra
)
def
test_z3interfaces
(
self
):
def
test_z3interfaces
(
self
):
from
Products.PluginIndexes.interfaces
import
IDateRangeIndex
from
Products.PluginIndexes.interfaces
import
IDateRangeIndex
...
@@ -87,14 +90,14 @@ class DRI_Tests( unittest.TestCase ):
...
@@ -87,14 +90,14 @@ class DRI_Tests( unittest.TestCase ):
from
Products.PluginIndexes.interfaces
import
IUniqueValueIndex
from
Products.PluginIndexes.interfaces
import
IUniqueValueIndex
from
zope.interface.verify
import
verifyClass
from
zope.interface.verify
import
verifyClass
verifyClass
(
IDateRangeIndex
,
DateRangeIndex
)
verifyClass
(
IDateRangeIndex
,
self
.
_getTargetClass
()
)
verifyClass
(
IPluggableIndex
,
DateRangeIndex
)
verifyClass
(
IPluggableIndex
,
self
.
_getTargetClass
()
)
verifyClass
(
ISortIndex
,
DateRangeIndex
)
verifyClass
(
ISortIndex
,
self
.
_getTargetClass
()
)
verifyClass
(
IUniqueValueIndex
,
DateRangeIndex
)
verifyClass
(
IUniqueValueIndex
,
self
.
_getTargetClass
()
)
def
test_empty
(
self
):
def
test_empty
(
self
):
empty
=
DateRangeIndex
(
'empty'
)
empty
=
self
.
_makeOne
(
'empty'
)
self
.
failUnless
(
empty
.
getEntryForObject
(
1234
)
is
None
)
self
.
failUnless
(
empty
.
getEntryForObject
(
1234
)
is
None
)
empty
.
unindex_object
(
1234
)
# shouldn't throw
empty
.
unindex_object
(
1234
)
# shouldn't throw
...
@@ -111,18 +114,18 @@ class DRI_Tests( unittest.TestCase ):
...
@@ -111,18 +114,18 @@ class DRI_Tests( unittest.TestCase ):
def
test_retrieval
(
self
):
def
test_retrieval
(
self
):
work
=
DateRangeIndex
(
'work'
,
'start'
,
'stop'
)
index
=
self
.
_makeOne
(
'work'
,
'start'
,
'stop'
)
for
i
in
range
(
len
(
dummies
)
):
for
i
in
range
(
len
(
dummies
)
):
work
.
index_object
(
i
,
dummies
[
i
]
)
index
.
index_object
(
i
,
dummies
[
i
]
)
for
i
in
range
(
len
(
dummies
)
):
for
i
in
range
(
len
(
dummies
)
):
self
.
assertEqual
(
work
.
getEntryForObject
(
i
),
dummies
[
i
].
datum
())
self
.
assertEqual
(
index
.
getEntryForObject
(
i
),
dummies
[
i
].
datum
())
for
value
in
range
(
-
1
,
15
):
for
value
in
range
(
-
1
,
15
):
matches
=
matchingDummies
(
value
)
matches
=
matchingDummies
(
value
)
results
,
used
=
work
.
_apply_index
(
{
'work'
:
value
}
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
value
}
)
self
.
assertEqual
(
used
,
(
'start'
,
'stop'
))
self
.
assertEqual
(
used
,
(
'start'
,
'stop'
))
self
.
assertEqual
(
len
(
matches
),
len
(
results
))
self
.
assertEqual
(
len
(
matches
),
len
(
results
))
...
@@ -130,43 +133,84 @@ class DRI_Tests( unittest.TestCase ):
...
@@ -130,43 +133,84 @@ class DRI_Tests( unittest.TestCase ):
matches
.
sort
(
lambda
x
,
y
:
cmp
(
x
.
name
(),
y
.
name
()
)
)
matches
.
sort
(
lambda
x
,
y
:
cmp
(
x
.
name
(),
y
.
name
()
)
)
for
result
,
match
in
map
(
None
,
results
,
matches
):
for
result
,
match
in
map
(
None
,
results
,
matches
):
self
.
assertEqual
(
work
.
getEntryForObject
(
result
),
match
.
datum
())
self
.
assertEqual
(
index
.
getEntryForObject
(
result
),
match
.
datum
())
def
test_longdates
(
self
):
def
test_longdates
(
self
):
self
.
assertRaises
(
OverflowError
,
self
.
_badlong
)
self
.
assertRaises
(
OverflowError
,
self
.
_badlong
)
def
_badlong
(
self
):
def
_badlong
(
self
):
work
=
DateRangeIndex
(
'work'
,
'start'
,
'stop'
)
import
sys
index
=
self
.
_makeOne
(
'work'
,
'start'
,
'stop'
)
bad
=
Dummy
(
'bad'
,
long
(
sys
.
maxint
)
+
1
,
long
(
sys
.
maxint
)
+
1
)
bad
=
Dummy
(
'bad'
,
long
(
sys
.
maxint
)
+
1
,
long
(
sys
.
maxint
)
+
1
)
work
.
index_object
(
0
,
bad
)
index
.
index_object
(
0
,
bad
)
def
test_datetime
(
self
):
def
test_datetime
(
self
):
from
datetime
import
datetime
from
datetime
import
datetime
from
DateTime.DateTime
import
DateTime
from
Products.PluginIndexes.DateIndex.tests.test_DateIndex
\
import
_getEastern
before
=
datetime
(
2009
,
7
,
11
,
0
,
0
,
tzinfo
=
_getEastern
())
start
=
datetime
(
2009
,
7
,
13
,
5
,
15
,
tzinfo
=
_getEastern
())
between
=
datetime
(
2009
,
7
,
13
,
5
,
45
,
tzinfo
=
_getEastern
())
stop
=
datetime
(
2009
,
7
,
13
,
6
,
30
,
tzinfo
=
_getEastern
())
after
=
datetime
(
2009
,
7
,
14
,
0
,
0
,
tzinfo
=
_getEastern
())
dummy
=
Dummy
(
'test'
,
start
,
stop
)
index
=
self
.
_makeOne
(
'work'
,
'start'
,
'stop'
)
index
.
index_object
(
0
,
dummy
)
self
.
assertEqual
(
index
.
getEntryForObject
(
0
),
(
DateTime
(
start
).
millis
()
/
60000
,
DateTime
(
stop
).
millis
()
/
60000
))
results
,
used
=
index
.
_apply_index
(
{
'work'
:
before
}
)
self
.
assertEqual
(
len
(
results
),
0
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
start
}
)
self
.
assertEqual
(
len
(
results
),
1
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
between
}
)
self
.
assertEqual
(
len
(
results
),
1
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
stop
}
)
self
.
assertEqual
(
len
(
results
),
1
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
after
}
)
self
.
assertEqual
(
len
(
results
),
0
)
def
test_datetime_naive_timezone
(
self
):
from
datetime
import
datetime
from
DateTime.DateTime
import
DateTime
from
Products.PluginIndexes.DateIndex.DateIndex
import
Local
before
=
datetime
(
2009
,
7
,
11
,
0
,
0
)
before
=
datetime
(
2009
,
7
,
11
,
0
,
0
)
start
=
datetime
(
2009
,
7
,
13
,
5
,
15
)
start
=
datetime
(
2009
,
7
,
13
,
5
,
15
)
start_local
=
datetime
(
2009
,
7
,
13
,
5
,
15
,
tzinfo
=
Local
)
between
=
datetime
(
2009
,
7
,
13
,
5
,
45
)
between
=
datetime
(
2009
,
7
,
13
,
5
,
45
)
stop
=
datetime
(
2009
,
7
,
13
,
6
,
30
)
stop
=
datetime
(
2009
,
7
,
13
,
6
,
30
)
stop_local
=
datetime
(
2009
,
7
,
13
,
6
,
30
,
tzinfo
=
Local
)
after
=
datetime
(
2009
,
7
,
14
,
0
,
0
)
after
=
datetime
(
2009
,
7
,
14
,
0
,
0
)
dummy
=
Dummy
(
'test'
,
start
,
stop
)
dummy
=
Dummy
(
'test'
,
start
,
stop
)
work
=
DateRangeIndex
(
'work'
,
'start'
,
'stop'
)
index
=
self
.
_makeOne
(
'work'
,
'start'
,
'stop'
)
work
.
index_object
(
0
,
dummy
)
index
.
index_object
(
0
,
dummy
)
self
.
assertEqual
(
work
.
getEntryForObject
(
0
),
(
20790915
,
20790990
))
self
.
assertEqual
(
index
.
getEntryForObject
(
0
),
(
DateTime
(
start_local
).
millis
()
/
60000
,
DateTime
(
stop_local
).
millis
()
/
60000
))
results
,
used
=
work
.
_apply_index
(
{
'work'
:
before
}
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
before
}
)
self
.
assertEqual
(
len
(
results
),
0
)
self
.
assertEqual
(
len
(
results
),
0
)
results
,
used
=
work
.
_apply_index
(
{
'work'
:
start
}
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
start
}
)
self
.
assertEqual
(
len
(
results
),
1
)
self
.
assertEqual
(
len
(
results
),
1
)
results
,
used
=
work
.
_apply_index
(
{
'work'
:
between
}
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
between
}
)
self
.
assertEqual
(
len
(
results
),
1
)
self
.
assertEqual
(
len
(
results
),
1
)
results
,
used
=
work
.
_apply_index
(
{
'work'
:
stop
}
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
stop
}
)
self
.
assertEqual
(
len
(
results
),
1
)
self
.
assertEqual
(
len
(
results
),
1
)
results
,
used
=
work
.
_apply_index
(
{
'work'
:
after
}
)
results
,
used
=
index
.
_apply_index
(
{
'work'
:
after
}
)
self
.
assertEqual
(
len
(
results
),
0
)
self
.
assertEqual
(
len
(
results
),
0
)
...
...
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