Commit 3b2c6ef1 authored by Nicolas Delaby's avatar Nicolas Delaby

test atTheEndOfPeriod function

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27521 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3b6591be
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2007 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2007 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -52,8 +53,7 @@ ZopeTestCase.installProduct('ERP5Type') ...@@ -52,8 +53,7 @@ ZopeTestCase.installProduct('ERP5Type')
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate from Products.ERP5Type.DateUtils import addToDate, getIntervalListBetweenDates, atTheEndOfPeriod
from Products.ERP5Type.DateUtils import getIntervalListBetweenDates
class TestDateUtils(unittest.TestCase): class TestDateUtils(unittest.TestCase):
""" """
...@@ -160,6 +160,13 @@ class TestDateUtils(unittest.TestCase): ...@@ -160,6 +160,13 @@ class TestDateUtils(unittest.TestCase):
elif index == 11: elif index == 11:
self.assertEqual(date, '2008-11-03') self.assertEqual(date, '2008-11-03')
def test_atTheEndOfPeriod(self):
date = DateTime('2008/01/01 00:00:00 UTC')
self.assertEqual(atTheEndOfPeriod(date, 'year').pCommonZ(), 'Jan. 1, 2009 12:00 am Universal')
self.assertEqual(atTheEndOfPeriod(date, 'month').pCommonZ(), 'Feb. 1, 2008 12:00 am Universal')
self.assertEqual(atTheEndOfPeriod(date, 'week').pCommonZ(), 'Jan. 7, 2008 12:00 am Universal')
self.assertEqual(atTheEndOfPeriod(date, 'day').pCommonZ(), 'Jan. 2, 2008 12:00 am Universal')
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestDateUtils)) suite.addTest(unittest.makeSuite(TestDateUtils))
......
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