Commit ea5bcae0 authored by Jérome Perrin's avatar Jérome Perrin

test person.getAvailableTime, person.getAvailableTimeSequence and

Person_getAvailableTimeMovementList when a leave request overlaps a group
calendar 


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23054 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e3f42149
......@@ -1015,6 +1015,78 @@ class TestCalendar(ERP5TypeTestCase):
to_date=DateTime(2008, 1, 7).latestTime())
self.assertEquals(0, len(available_time_movement_list))
def test_LeaveRequestOverlappingGroupCalendar(self):
group_calendar = self.portal.group_calendar_module.newContent(
portal_type='Group Calendar')
group_calendar_period = group_calendar.newContent(
portal_type='Group Presence Period')
group_calendar_period.setStartDate('2008/01/01 08:00')
group_calendar_period.setStopDate('2008/01/01 18:00')
group_calendar_period.setResourceValue(
self.portal.portal_categories.calendar_period_type.type1)
group_calendar.confirm()
person = self.portal.person_module.newContent(portal_type='Person')
assignment = person.newContent(portal_type='Assignment',
calendar_value=group_calendar)
get_transaction().commit()
self.tic()
self.assertEquals((18 - 8) * 60 * 60, person.getAvailableTime(
from_date=DateTime(2008, 1, 1).earliestTime(),
to_date=DateTime(2008, 1, 1).latestTime()))
self.assertEquals([(18 - 8) * 60 * 60],
[x.total_quantity for x in person.getAvailableTimeSequence(
day=1,
from_date=DateTime(2008, 1, 1).earliestTime(),
to_date=DateTime(2008, 1, 1).latestTime())])
available_time_movement_list = person.Person_getAvailableTimeMovementList(
from_date=DateTime(2008, 1, 1).earliestTime(),
to_date=DateTime(2008, 1, 1).latestTime())
self.assertEquals(1, len(available_time_movement_list))
self.assertEquals(
[(DateTime('2008/01/01 08:00'), DateTime('2008/01/01 18:00'))],
[(m.getStartDate(), m.getStopDate()) for m in
available_time_movement_list])
leave_request = self.portal.leave_request_module.newContent(
portal_type='Leave Request')
leave_request_period = leave_request.newContent(
portal_type='Leave Request Period')
leave_request_period.setStartDate('2008/01/01 09:00')
leave_request_period.setStopDate('2008/01/01 17:00')
leave_request_period.setResourceValue(
self.portal.portal_categories.calendar_period_type.type1)
leave_request.setDestinationValue(person)
leave_request.confirm()
get_transaction().commit()
self.tic()
self.assertEquals((9-8 + 18-17) * 60 * 60, person.getAvailableTime(
from_date=DateTime(2008, 1, 1).earliestTime(),
to_date=DateTime(2008, 1, 1).latestTime()))
self.assertEquals([(9-8 + 18-17) * 60 * 60],
[x.total_quantity for x in person.getAvailableTimeSequence(
day=1,
from_date=DateTime(2008, 1, 1).earliestTime(),
to_date=DateTime(2008, 1, 1).latestTime())])
available_time_movement_list = person.Person_getAvailableTimeMovementList(
from_date=DateTime(2008, 1, 1).earliestTime(),
to_date=DateTime(2008, 1, 1).latestTime())
self.assertEquals(2, len(available_time_movement_list))
self.assertEquals(
[(DateTime('2008/01/01 08:00').ISO(),
DateTime('2008/01/01 09:00').ISO()),
(DateTime('2008/01/01 16:59:59').ISO(), # XXX is it good ?
DateTime('2008/01/01 18:00').ISO())],
[(m.getStartDate().ISO(), m.getStopDate().ISO()) for m in
available_time_movement_list])
import unittest
def test_suite():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment