##############################################################################
#
# 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.1 (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.
#
##############################################################################
"""Float Widget Functional Tests
$Id: test_floatwidget.py 67630 2006-04-27 00:54:03Z jim $
"""
import unittest
import transaction
from persistent import Persistent
import zope.security.checker
from zope.interface import Interface, implements
from zope.traversing.api import traverse
from zope.schema import Float, Choice
from zope.app.form.browser.ftests.support import *
from zope.app.testing.functional import BrowserTestCase
class IFloatTest(Interface):
f1 = Float(
required=False,
min=1.1,
max=10.1)
f2 = Float(
required=False)
f3 = Choice(
required=True,
values=(0.0, 1.1, 2.1, 3.1, 5.1, 7.1, 11.1),
missing_value=0)
class FloatTest(Persistent):
implements(IFloatTest)
def __init__(self):
self.f1 = None
self.f2 = 1.1
self.f3 = 2.1
class Test(BrowserTestCase):
def setUp(self):
BrowserTestCase.setUp(self)
registerEditForm(IFloatTest)
defineSecurity(FloatTest, IFloatTest)
def test_display_editform(self):
self.getRootFolder()['test'] = FloatTest()
transaction.commit()
# display edit view
response = self.publish('/test/edit.html')
self.assertEqual(response.getStatus(), 200)
# f1 and f2 should be displayed in text fields
self.assert_(patternExists(
'', response.getBody()))
self.assert_(patternExists(
'', response.getBody()))
# f3 should be in a dropdown
self.assert_(patternExists(
'