[Zope3-checkins] CVS: Zope3/src/zope/publisher/tests - test_browsermarshalling.py:1.1

Tres Seaver tseaver@zope.com
Thu, 13 Feb 2003 00:06:28 -0500


Update of /cvs-repository/Zope3/src/zope/publisher/tests
In directory cvs.zope.org:/tmp/cvs-serv20260/src/zope/publisher/tests

Added Files:
	test_browsermarshalling.py 
Log Message:


  - Make 'field2date' marshaller return a new-style datetime (naive until
    we have infrastructure for looking up 'tzinfo' objects by name);  added
    module for testing marshalling.


=== Added File Zope3/src/zope/publisher/tests/test_browsermarshalling.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""

Revision information:
$Id: test_browsermarshalling.py,v 1.1 2003/02/13 05:06:27 tseaver Exp $
"""

from unittest import TestCase, TestSuite, main, makeSuite
from datetime import datetime

class TestBrowserMarshalling(TestCase):

    def test_field2date_dateonly(self):

        from zope.publisher.browser import field2date

        dt = field2date('2003/05/04')
        self.failUnless(isinstance(dt, datetime))
        self.assertEqual(dt.year, 2003)
        self.assertEqual(dt.month, 5)
        self.assertEqual(dt.day, 4)
        self.assertEqual(dt.hour, 0)
        self.assertEqual(dt.minute, 0)
        self.assertEqual(dt.second, 0)
        self.assertEqual(dt.tzinfo, None)

    def test_field2date_timestamp(self):

        from zope.publisher.browser import field2date

        dt = field2date('2003/05/04 19:26:54')
        self.failUnless(isinstance(dt, datetime))
        self.assertEqual(dt.year, 2003)
        self.assertEqual(dt.month, 5)
        self.assertEqual(dt.day, 4)
        self.assertEqual(dt.hour, 19)
        self.assertEqual(dt.minute, 26)
        self.assertEqual(dt.second, 54)
        self.assertEqual(dt.tzinfo, None)

def test_suite():
    suite = TestSuite()
    suite.addTest(makeSuite(TestBrowserMarshalling))
    return suite


if __name__ == '__main__':
    main()