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
Joshua
erp5
Commits
188ed4de
Commit
188ed4de
authored
Dec 04, 2006
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
d444ec9b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
30 deletions
+50
-30
product/ERP5/Document/Periodicity.py
product/ERP5/Document/Periodicity.py
+5
-1
product/ERP5/tests/testAlarm.py
product/ERP5/tests/testAlarm.py
+45
-29
No files found.
product/ERP5/Document/Periodicity.py
View file @
188ed4de
##############################################################################
##############################################################################
#
#
# Copyright (c) 200
4
Nexedi SARL and Contributors. All Rights Reserved.
# Copyright (c) 200
6
Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
# Sebastien Robin <seb@nexedi.com>
#
#
# WARNING: This program as such is intended to be used by professional
# WARNING: This program as such is intended to be used by professional
...
@@ -181,6 +181,10 @@ class Periodicity(Base):
...
@@ -181,6 +181,10 @@ class Periodicity(Base):
else
:
else
:
if
not
(
validate_day
and
validate_week
and
validate_month
):
if
not
(
validate_day
and
validate_week
and
validate_month
):
next_start_date
=
addToDate
(
next_start_date
,
day
=
1
)
next_start_date
=
addToDate
(
next_start_date
,
day
=
1
)
else
:
# Everything is right, but the date is still not bigger
# than the current date, so we must continue
next_start_date
=
addToDate
(
next_start_date
,
minute
=
1
)
self
.
Alarm_zUpdateAlarmDate
(
uid
=
self
.
getUid
(),
alarm_date
=
next_start_date
)
self
.
Alarm_zUpdateAlarmDate
(
uid
=
self
.
getUid
(),
alarm_date
=
next_start_date
)
...
...
product/ERP5/tests/testAlarm.py
View file @
188ed4de
##############################################################################
##############################################################################
#
#
# Copyright (c) 200
4
Nexedi SARL and Contributors. All Rights Reserved.
# Copyright (c) 200
6
Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
# Sebastien Robin <seb@nexedi.com>
#
#
# WARNING: This program as such is intended to be used by professional
# WARNING: This program as such is intended to be used by professional
...
@@ -199,11 +199,11 @@ class TestAlarm(ERP5TypeTestCase):
...
@@ -199,11 +199,11 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
LOG
(
'Testing... '
,
0
,
message
)
LOG
(
'Testing... '
,
0
,
message
)
# year/month/day hour:minute:second
# year/month/day hour:minute:second
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
6
,
15
,
00
,
00
))
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
6
,
15
,
00
,
00
))
now
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
6
,
15
,
00
,
00
))
now
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
6
,
15
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
6
,
21
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
6
,
21
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
7
,
06
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
7
,
06
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
7
,
10
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
7
,
10
,
00
,
00
))
alarm
=
self
.
newAlarm
()
alarm
=
self
.
newAlarm
()
hour_list
=
(
6
,
10
,
15
,
21
)
hour_list
=
(
6
,
10
,
15
,
21
)
alarm
.
setPeriodicityStartDate
(
now
)
alarm
.
setPeriodicityStartDate
(
now
)
...
@@ -225,10 +225,10 @@ class TestAlarm(ERP5TypeTestCase):
...
@@ -225,10 +225,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
LOG
(
'Testing... '
,
0
,
message
)
LOG
(
'Testing... '
,
0
,
message
)
# year/month/day hour:minute:second
# year/month/day hour:minute:second
now
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
6
,
10
,
00
,
00
))
now
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
6
,
10
,
00
,
00
))
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
6
,
10
,
00
,
00
))
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
6
,
10
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
7
,
10
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
7
,
10
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
8
,
10
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
8
,
10
,
00
,
00
))
alarm
=
self
.
newAlarm
()
alarm
=
self
.
newAlarm
()
alarm
.
setPeriodicityStartDate
(
now
)
alarm
.
setPeriodicityStartDate
(
now
)
alarm
.
setPeriodicityDayFrequency
(
1
)
alarm
.
setPeriodicityDayFrequency
(
1
)
...
@@ -249,10 +249,10 @@ class TestAlarm(ERP5TypeTestCase):
...
@@ -249,10 +249,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
LOG
(
'Testing... '
,
0
,
message
)
LOG
(
'Testing... '
,
0
,
message
)
# year/month/day hour:minute:second
# year/month/day hour:minute:second
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
6
,
14
,
00
,
00
))
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
6
,
14
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
6
,
15
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
6
,
15
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
6
,
17
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
6
,
17
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
9
,
14
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
9
,
14
,
00
,
00
))
alarm
=
self
.
newAlarm
()
alarm
=
self
.
newAlarm
()
alarm
.
setPeriodicityStartDate
(
right_first_date
)
alarm
.
setPeriodicityStartDate
(
right_first_date
)
alarm
.
setPeriodicityDayFrequency
(
3
)
alarm
.
setPeriodicityDayFrequency
(
3
)
...
@@ -275,10 +275,10 @@ class TestAlarm(ERP5TypeTestCase):
...
@@ -275,10 +275,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
LOG
(
'Testing... '
,
0
,
message
)
LOG
(
'Testing... '
,
0
,
message
)
# year/month/day hour:minute:second
# year/month/day hour:minute:second
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
9
,
27
,
6
,
00
,
00
))
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
9
,
27
,
6
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
9
,
27
,
15
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
9
,
29
,
15
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
1
,
6
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
2
,
6
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
1
,
15
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
2
,
15
,
00
,
00
))
alarm
=
self
.
newAlarm
()
alarm
=
self
.
newAlarm
()
get_transaction
().
commit
()
get_transaction
().
commit
()
self
.
tic
()
self
.
tic
()
...
@@ -313,10 +313,10 @@ class TestAlarm(ERP5TypeTestCase):
...
@@ -313,10 +313,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
LOG
(
'Testing... '
,
0
,
message
)
LOG
(
'Testing... '
,
0
,
message
)
# year/month/day hour:minute:second
# year/month/day hour:minute:second
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
01
,
12
,
00
,
00
))
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
01
,
12
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
01
,
14
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
01
,
14
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
15
,
12
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
15
,
12
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
15
,
14
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
15
,
14
,
00
,
00
))
alarm
=
self
.
newAlarm
()
alarm
=
self
.
newAlarm
()
alarm
.
setPeriodicityStartDate
(
right_first_date
)
alarm
.
setPeriodicityStartDate
(
right_first_date
)
alarm
.
setPeriodicityMonthDayList
((
1
,
15
))
alarm
.
setPeriodicityMonthDayList
((
1
,
15
))
...
@@ -333,9 +333,9 @@ class TestAlarm(ERP5TypeTestCase):
...
@@ -333,9 +333,9 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
LOG
(
'Testing... '
,
0
,
message
)
LOG
(
'Testing... '
,
0
,
message
)
# year/month/day hour:minute:second
# year/month/day hour:minute:second
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
01
,
6
,
00
,
00
))
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
01
,
6
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
12
,
01
,
6
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
12
,
01
,
6
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
5
,
2
,
01
,
6
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
7
,
2
,
01
,
6
,
00
,
00
))
alarm
=
self
.
newAlarm
()
alarm
=
self
.
newAlarm
()
alarm
.
setPeriodicityStartDate
(
right_first_date
)
alarm
.
setPeriodicityStartDate
(
right_first_date
)
alarm
.
setPeriodicityMonthDayList
((
1
,))
alarm
.
setPeriodicityMonthDayList
((
1
,))
...
@@ -352,10 +352,10 @@ class TestAlarm(ERP5TypeTestCase):
...
@@ -352,10 +352,10 @@ class TestAlarm(ERP5TypeTestCase):
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
LOG
(
'Testing... '
,
0
,
message
)
LOG
(
'Testing... '
,
0
,
message
)
# year/month/day hour:minute:second
# year/month/day hour:minute:second
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
10
,
6
,
00
,
00
))
right_first_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
1
,
6
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
18
,
6
,
00
,
00
))
right_second_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
9
,
6
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
19
,
6
,
00
,
00
))
right_third_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
10
,
6
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
4
,
10
,
20
,
6
,
00
,
00
))
right_fourth_date
=
DateTime
(
'%i/%i/%i %i:%i:%d'
%
(
200
6
,
10
,
11
,
6
,
00
,
00
))
alarm
=
self
.
newAlarm
()
alarm
=
self
.
newAlarm
()
alarm
.
setPeriodicityStartDate
(
right_first_date
)
alarm
.
setPeriodicityStartDate
(
right_first_date
)
alarm
.
setPeriodicityHourList
((
6
,))
alarm
.
setPeriodicityHourList
((
6
,))
...
@@ -392,6 +392,22 @@ class TestAlarm(ERP5TypeTestCase):
...
@@ -392,6 +392,22 @@ class TestAlarm(ERP5TypeTestCase):
next_date
=
addToDate
(
next_date
,
minute
=
5
)
next_date
=
addToDate
(
next_date
,
minute
=
5
)
self
.
assertEquals
(
alarm
.
getAlarmDate
(),
next_date
)
self
.
assertEquals
(
alarm
.
getAlarmDate
(),
next_date
)
def
test_13_EveryMinute
(
self
,
quiet
=
0
,
run
=
run_all_test
):
if
not
run
:
return
if
not
quiet
:
message
=
'Test Every Minute'
ZopeTestCase
.
_print
(
'
\
n
%s '
%
message
)
LOG
(
'Testing... '
,
0
,
message
)
alarm
=
self
.
newAlarm
()
now
=
DateTime
()
date
=
addToDate
(
now
,
hour
=
2
)
alarm
.
setPeriodicityStartDate
(
now
)
alarm
.
setPeriodicityMinuteFrequency
(
1
)
get_transaction
().
commit
()
self
.
tic
()
alarm
.
setNextAlarmDate
(
current_date
=
date
)
self
.
assertEquals
(
alarm
.
getAlarmDate
(),
date
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
framework
()
framework
()
else
:
else
:
...
...
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