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
Titouan Soulard
erp5
Commits
82a57949
Commit
82a57949
authored
Mar 23, 2022
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into zope4py2
parents
b35b8d44
32e04c8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
12 deletions
+41
-12
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testDateUtils.py
...TemplateItem/portal_components/test.erp5.testDateUtils.py
+25
-0
bt5/erp5_payroll_l10n_fr/TestTemplateItem/portal_components/test.erp5.testDSNSocialDeclarationReport.py
...al_components/test.erp5.testDSNSocialDeclarationReport.py
+1
-7
product/ERP5Type/tests/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+14
-4
scalability_test/example/scalabilityUsers.py
scalability_test/example/scalabilityUsers.py
+1
-1
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testDateUtils.py
View file @
82a57949
...
...
@@ -32,6 +32,7 @@ import unittest
from
DateTime
import
DateTime
from
erp5.component.module.DateUtils
import
addToDate
,
getIntervalListBetweenDates
,
\
atTheEndOfPeriod
,
getClosestDate
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
class
TestDateUtils
(
unittest
.
TestCase
):
"""
...
...
@@ -175,7 +176,31 @@ class TestDateUtils(unittest.TestCase):
self
.
assertEqual
(
'Sep. 10, 2008 12:00 am GMT-2'
,
getClosestDate
(
date
=
date
,
target_date
=
target_date
,
precision
=
'month'
,
before
=
False
).
pCommonZ
())
class
TestPinDateTime
(
ERP5TypeTestCase
):
def
test_pinDateTime
(
self
):
actual_begin_date
=
DateTime
()
datetime
=
DateTime
(
'2001/01/01 01:01:01'
)
fixed_date_with_timezone
=
DateTime
(
'2002/02/02 02:02:02 GMT+2'
)
self
.
pinDateTime
(
datetime
)
self
.
assertEqual
(
DateTime
(),
datetime
)
self
.
assertEqual
(
DateTime
(
'2002/02/02 02:02:02 GMT+2'
),
fixed_date_with_timezone
)
self
.
unpinDateTime
()
self
.
assertGreaterEqual
(
DateTime
(),
actual_begin_date
)
def
test_pinDateTime_context_manager
(
self
):
actual_begin_date
=
DateTime
()
datetime
=
DateTime
(
'2001/01/01 01:01:01'
)
with
self
.
pinDateTime
(
datetime
):
self
.
assertEqual
(
DateTime
(),
datetime
)
self
.
assertGreaterEqual
(
DateTime
(),
actual_begin_date
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestDateUtils
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestPinDateTime
))
return
suite
bt5/erp5_payroll_l10n_fr/TestTemplateItem/portal_components/test.erp5.testDSNSocialDeclarationReport.py
View file @
82a57949
...
...
@@ -31,12 +31,6 @@ import time
from
DateTime
import
DateTime
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
# As tests rely on documents exported in test bt5, setting up timezone allows
# consistency between test environment execution and virtual ERP5 instance
os
.
environ
[
'TZ'
]
=
'GMT'
time
.
tzset
()
DateTime
.
_localzone0
=
'GMT'
class
TestDSNSocialDeclarationReport
(
ERP5TypeTestCase
):
"""
Test Suite for the generation of the French Social Declaration Report,
...
...
@@ -50,8 +44,8 @@ class TestDSNSocialDeclarationReport(ERP5TypeTestCase):
"""
This is ran before anything, used to set the environment
"""
self
.
portal
=
self
.
getPortalObject
()
self
.
dsn_module
=
self
.
portal
.
getDefaultModuleValue
(
"DSN Monthly Report"
)
self
.
setTimeZoneToUTC
()
self
.
pinDateTime
(
DateTime
(
2015
,
12
,
01
))
# Create the id_group 'dsn_event_counter'
self
.
portal
.
portal_ids
.
generateNewId
(
id_group
=
'dsn_event_counter'
,
id_generator
=
'continuous_integer_increasing'
)
...
...
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
82a57949
...
...
@@ -373,12 +373,25 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
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
# infinitely fast),
for example
to avoid errors on tests that are started
# just before midnight.
# This can be used as a context manager, otherwise use unpinDateTime to
# reset.
global
_pinned_date_time
assert
date_time
is
None
or
isinstance
(
date_time
,
DateTime
)
_pinned_date_time
=
date_time
unpinDateTime
=
self
.
unpinDateTime
class
UnpinContextManager
(
object
):
def
__enter__
(
self
):
return
self
def
__exit__
(
self
,
*
args
):
unpinDateTime
()
return
UnpinContextManager
()
def
unpinDateTime
(
self
):
self
.
pinDateTime
(
None
)
def
setTimeZoneToUTC
(
self
):
# Make sure tests runs with UTC timezone. Some tests are checking values
# based on now, and this could give unexpected results:
...
...
@@ -393,9 +406,6 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
mock
.
patch
.
object
(
sys
.
modules
[
'DateTime.DateTime'
],
'_multipleZones'
,
new
=
False
).
start
()
def
unpinDateTime
(
self
):
self
.
pinDateTime
(
None
)
def
getDefaultSystemPreference
(
self
):
id
=
'default_system_preference'
tool
=
self
.
getPreferenceTool
()
...
...
scalability_test/example/scalabilityUsers.py
View file @
82a57949
# Specify user login/password used to run the tests.
# <password> and <user_quantity> will be automatically replaced by testnode for each configuration
user_tuple
=
tuple
([(
'scalability_user_%i'
%
x
,
"<password>"
)
for
x
in
range
(
0
,
<
user_quantity
>
)])
\ No newline at end of file
user_tuple
=
tuple
([(
'scalability_user_%i'
%
x
,
"<password>"
)
for
x
in
range
(
0
,
int
(
'<user_quantity>'
))])
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