Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexander Emmerich
erp5
Commits
43c8d0b5
Commit
43c8d0b5
authored
May 18, 2012
by
Yusei Tahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test DateTimeKey in multiple timezones. To test it in UTC only is not enough.
parent
5251d99a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
45 deletions
+63
-45
product/ZSQLCatalog/tests/testSQLCatalog.py
product/ZSQLCatalog/tests/testSQLCatalog.py
+63
-45
No files found.
product/ZSQLCatalog/tests/testSQLCatalog.py
View file @
43c8d0b5
...
...
@@ -37,6 +37,7 @@ from Products.ZSQLCatalog.Query.EntireQuery import EntireQuery
from
Products.ZSQLCatalog.Query.RelatedQuery
import
RelatedQuery
from
DateTime
import
DateTime
from
Products.ZSQLCatalog.SQLExpression
import
MergeConflictError
from
Products.ERP5Type.tests.backportUnittest
import
expectedFailure
class
MatchList
(
list
):
def
__repr__
(
self
):
...
...
@@ -220,10 +221,14 @@ class TestSQLCatalog(unittest.TestCase):
self
.
assertRaises
(
exception
,
self
.
_catalog
,
src__
=
1
,
query_table
=
'foo'
,
**
kw
)
def
catalog
(
self
,
reference_tree
,
kw
,
check_search_text
=
True
,
check_select_expression
=
True
):
check_select_expression
=
True
,
expected_failure
=
False
):
reference_param_dict
=
self
.
_catalog
.
_queryResults
(
query_table
=
'foo'
,
**
kw
)
query
=
self
.
_catalog
.
buildQuery
(
kw
)
self
.
assertEqual
(
reference_tree
,
query
)
assertEqual
=
self
.
assertEqual
if
expected_failure
:
assertEqual
=
expectedFailure
(
assertEqual
)
assertEqual
(
reference_tree
,
query
)
search_text
=
query
.
asSearchTextExpression
(
self
.
_catalog
)
if
check_search_text
:
# XXX: sould "keyword" be always used for search text searches ?
...
...
@@ -231,7 +236,7 @@ class TestSQLCatalog(unittest.TestCase):
if
not
check_select_expression
:
search_text_param_dict
.
pop
(
'select_expression'
)
reference_param_dict
.
pop
(
'select_expression'
)
self
.
assertEqual
(
reference_param_dict
,
search_text_param_dict
,
assertEqual
(
reference_param_dict
,
search_text_param_dict
,
'Query: %r
\
n
SearchText: %r
\
n
Reference: %r
\
n
Second rendering: %r'
%
\
(
query
,
search_text
,
reference_param_dict
,
search_text_param_dict
))
...
...
@@ -291,7 +296,7 @@ class TestSQLCatalog(unittest.TestCase):
{
'default'
:
{
'query'
:
'<a'
,
'key'
:
'ExactMatch'
}},
check_search_text
=
False
)
def
_testDateTimeKey
(
self
,
column
):
def
_testDateTimeKey
(
self
,
column
,
timezone
):
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/10/01 12:10:21'
)),
operator
=
'and'
),
{
column
:
{
'query'
:
'>2008/10/01 12:10:20'
,
'format'
:
'%y/%m/%d'
}})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/10/01 12:10:21 CEST'
)),
operator
=
'and'
),
...
...
@@ -299,71 +304,82 @@ class TestSQLCatalog(unittest.TestCase):
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/10/01 12:10:21 CET'
)),
operator
=
'and'
),
{
column
:
{
'query'
:
'>2008/10/01 12:10:20 CET'
,
'format'
:
'%y/%m/%d'
}})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/10/01 UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/10/02 UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/10/01 %s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/10/02 %s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008/10/01 %s'
%
timezone
})
if
timezone
==
'GMT+9'
:
# Very temporary expected failure. Expected failure mark must be removed soon.(Yusei)
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/01/01 %s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2009/01/01 %s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008/10/01 UTC'
})
{
column
:
'2008 %s'
%
timezone
},
expected_failure
=
True
)
else
:
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/01/01 UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2009/01/01 UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/01/01 %s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2009/01/01 %s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008 UTC'
})
{
column
:
'2008 %s'
%
timezone
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/01/01
UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/01
UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/01/01
%s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/01
%s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008/01
UTC'
})
{
column
:
'2008/01
%s'
%
timezone
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/10/01
UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/10/02
UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/10/01
%s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/10/02
%s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
{
'type'
:
'date'
,
'query'
:
'10/01/2008
UTC'
,
'format'
:
'%m/%d/%Y'
}})
{
column
:
{
'type'
:
'date'
,
'query'
:
'10/01/2008
%s'
%
timezone
,
'format'
:
'%m/%d/%Y'
}})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/10/01
UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/10/02
UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/10/01
%s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/10/02
%s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
{
'type'
:
'date'
,
'query'
:
'01/10/2008
UTC'
,
'format'
:
'%d/%m/%Y'
}})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'in'
,
date
=
[
DateTime
(
'2008/01/10
UTC'
),
DateTime
(
'2008/01/09 UTC'
)]),
operator
=
'and'
),
{
column
:
{
'query'
:
[
'2008/01/10
UTC'
,
'2008/01/09 UTC'
],
'operator'
:
'in'
}},
{
column
:
{
'type'
:
'date'
,
'query'
:
'01/10/2008
%s'
%
timezone
,
'format'
:
'%d/%m/%Y'
}})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'in'
,
date
=
[
DateTime
(
'2008/01/10
%s'
%
timezone
),
DateTime
(
'2008/01/09 %s'
%
timezone
)]),
operator
=
'and'
),
{
column
:
{
'query'
:
[
'2008/01/10
%s'
%
timezone
,
'2008/01/09 %s'
%
timezone
],
'operator'
:
'in'
}},
check_search_text
=
False
)
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>'
,
date
=
DateTime
(
'2008/01/10
UTC'
)),
operator
=
'and'
),
{
column
:
{
'query'
:
'2008/01/10
UTC'
,
'range'
:
'nlt'
}},
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>'
,
date
=
DateTime
(
'2008/01/10
%s'
%
timezone
)),
operator
=
'and'
),
{
column
:
{
'query'
:
'2008/01/10
%s'
%
timezone
,
'range'
:
'nlt'
}},
check_search_text
=
False
)
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/01/01
UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2009/01/01
UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/01/01
%s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2009/01/01
%s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008
UTC'
})
{
column
:
'2008
%s'
%
timezone
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/01
UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/03/01
UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/01
%s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/03/01
%s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008/02
UTC'
})
{
column
:
'2008/02
%s'
%
timezone
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/02
UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/03
UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/02
%s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/03
%s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008/02/02
UTC'
})
{
column
:
'2008/02/02
%s'
%
timezone
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/02 10:00:00
UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/02 11:00:00
UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/02 10:00:00
%s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/02 11:00:00
%s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008/02/02 10
UTC'
})
{
column
:
'2008/02/02 10
%s'
%
timezone
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/02 10:10:00
UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/02 10:11:00
UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/02 10:10:00
%s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/02 10:11:00
%s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008/02/02 10:10
UTC'
})
{
column
:
'2008/02/02 10:10
%s'
%
timezone
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/02 10:10:10
UTC'
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/02 10:10:11
UTC'
))
ReferenceQuery
(
operator
=
'>='
,
date
=
DateTime
(
'2008/02/02 10:10:10
%s'
%
timezone
)),
ReferenceQuery
(
operator
=
'<'
,
date
=
DateTime
(
'2008/02/02 10:10:11
%s'
%
timezone
))
,
operator
=
'and'
),
operator
=
'and'
),
{
column
:
'2008/02/02 10:10:10
UTC'
})
{
column
:
'2008/02/02 10:10:10
%s'
%
timezone
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'is'
,
date
=
None
),
operator
=
'and'
),
{
column
:
None
},
check_search_text
=
False
)
def
test_DateTimeKey
(
self
):
self
.
_testDateTimeKey
(
'date'
)
# Try multiple timezones
self
.
_testDateTimeKey
(
'date'
,
'UTC'
)
self
.
_testDateTimeKey
(
'date'
,
'GMT+9'
)
# XXX: It is unknown what these tests should produce when used with a
# related key: should the join happen or not ?
self
.
catalog
(
...
...
@@ -380,7 +396,9 @@ class TestSQLCatalog(unittest.TestCase):
{
'date'
:
'00:00:00'
})
def
test_relatedDateTimeKey
(
self
):
self
.
_testDateTimeKey
(
'related_date'
)
# Try multiple timezones
self
.
_testDateTimeKey
(
'related_date'
,
'UTC'
)
self
.
_testDateTimeKey
(
'related_date'
,
'GMT+9'
)
def
_testKeywordKey
(
self
,
column
):
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'like'
,
keyword
=
'%a%'
),
operator
=
'and'
),
...
...
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