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
1
Issues
1
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
Roque
erp5
Commits
9b5fddcd
Commit
9b5fddcd
authored
Jun 25, 2012
by
Leonardo Rochael Almeida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix random errors when tests are run close to midnight
parent
a7f0bbb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
product/ERP5/tests/testOrder.py
product/ERP5/tests/testOrder.py
+17
-3
product/ERP5Type/tests/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+27
-0
No files found.
product/ERP5/tests/testOrder.py
View file @
9b5fddcd
...
...
@@ -51,7 +51,8 @@ class TestOrderMixin(SubcontentReindexingWrapper):
order_cell_portal_type
=
'Sale Order Cell'
applied_rule_portal_type
=
'Applied Rule'
simulation_movement_portal_type
=
'Simulation Movement'
datetime
=
DateTime
()
# see comment about self.datetime on afterSetUp() below
datetime
=
DateTime
()
-
2
packing_list_portal_type
=
'Sale Packing List'
packing_list_line_portal_type
=
'Sale Packing List Line'
packing_list_cell_portal_type
=
'Sale Packing List Cell'
...
...
@@ -94,15 +95,28 @@ class TestOrderMixin(SubcontentReindexingWrapper):
preference
.
enable
()
self
.
tic
()
def
afterSetUp
(
self
,
quiet
=
1
,
run
=
1
):
def
afterSetUp
(
self
):
# XXX-Leo: cannot call super here, because other classes call
# SuperClass.afterSetUp(self) directly... this needs to be cleaned
# up, including consolidating all conflicting definitions of
# .createCategories()
#super(TestOrderMixin, self).afterSetUp()
self
.
login
()
portal
=
self
.
getPortal
()
self
.
category_tool
=
self
.
getCategoryTool
()
portal_catalog
=
self
.
getCatalogTool
()
#portal_catalog.manage_catalogClear()
self
.
createCategories
()
self
.
validateRules
()
self
.
setUpPreferences
()
# pin datetime on the day before yesterday, to make sure that:
#
# 1. All calculations are done relative to the same time
# 2. We don't get random failures when tests run close to midnight
self
.
pinDateTime
(
self
.
datetime
)
def
beforeTearDown
(
self
):
self
.
unpinDateTime
()
super
(
TestOrderMixin
,
self
).
beforeTearDown
()
def
createCurrency
(
self
):
currency_module
=
self
.
getPortal
().
currency_module
...
...
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
9b5fddcd
...
...
@@ -26,6 +26,7 @@ from hashlib import md5
from
warnings
import
warn
from
ExtensionClass
import
pmc_init_of
from
ZTUtils
import
make_query
from
DateTime
import
DateTime
# XXX make sure that get_request works.
import
Products.ERP5Type.Utils
...
...
@@ -275,6 +276,21 @@ def profile_if_environ(environment_var_name):
# No profiling, return identity decorator
return
lambda
self
,
method
:
method
# Patch DateTime to allow pinning the notion of "now".
assert
getattr
(
DateTime
,
'_original_parse_args'
,
None
)
is
None
DateTime
.
_original_parse_args
=
DateTime
.
_parse_args
_pinned_date_time
=
None
def
_parse_args
(
self
,
*
args
,
**
kw
):
if
_pinned_date_time
is
not
None
and
(
not
args
or
args
[
0
]
==
None
):
# simulate fixed "Now"
args
=
(
_pinned_date_time
,)
+
args
[
1
:]
return
self
.
_original_parse_args
(
*
args
,
**
kw
)
_parse_args
.
_original
=
DateTime
.
_original_parse_args
DateTime
.
_parse_args
=
_parse_args
class
ERP5TypeTestCaseMixin
(
ProcessingNodeTestCase
,
PortalTestCase
):
"""Mixin class for ERP5 based tests.
"""
...
...
@@ -354,6 +370,17 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
cls
.
__bases__
=
cls
.
__bases__
[
1
:]
pmc_init_of
(
cls
)
def
pinDateTime
(
self
,
date_time
):
# pretend time has stopped at a certain date (i.e. the test runs
# infinitely fast), to avoid errors on tests that are started
# just before midnight.
global
_pinned_date_time
assert
date_time
is
None
or
isinstance
(
date_time
,
DateTime
)
_pinned_date_time
=
date_time
def
unpinDateTime
(
self
):
self
.
pinDateTime
(
None
)
def
getDefaultSitePreferenceId
(
self
):
"""Default id, usefull method to override
"""
...
...
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