class ICaseStudy(IAceMeasure): """ Case study """ # location - a clickable map, not provided if is "Adaptation option" type location_lat = Decimal(title=_(u"Location latitude"), required=True) location_lon = Decimal(title=_(u"Location longitude"), required=True)
class IDecimalTest(Interface): f1 = Decimal(required=False, min=decimal.Decimal("1.1"), max=decimal.Decimal("10.1")) f2 = Decimal(required=False) f3 = Choice(required=True, values=(decimal.Decimal("0.0"), decimal.Decimal("1.1"), decimal.Decimal("2.1"), decimal.Decimal("3.1"), decimal.Decimal("5.1"), decimal.Decimal("7.1"), decimal.Decimal("11.1")), missing_value=0)
def test_w_fields(self): from zope.schema import Text from zope.schema import Bytes from zope.schema import Int from zope.schema import Float from zope.schema import Decimal self.assertEqual(self._callFUT([Text()]), True) self.assertEqual(self._callFUT([Bytes()]), True) self.assertEqual(self._callFUT([Int()]), True) self.assertEqual(self._callFUT([Float()]), True) self.assertEqual(self._callFUT([Decimal()]), True) self.assertEqual(self._callFUT( [Text(), Bytes(), Int(), Float(), Decimal()]), True)
class ISiteTemplate(Interface): """ describes the template for creating a site """ id = TextLine(title=u'Template ID', description=u'ID must be a valid python identifier', required=True) name = TextLine(title=u'Template Name', required=True) description = Text( title=u"Template Description", description=u"The description of this template shown to users", required=True) price = Decimal( title=u"Template Price", description= u"The price users will be charged per subscription period for a site built from this template", required=True) products = FrozenSet( title=u"Installed Products", description= u"Choose the products to install when creating a site from this template", required=True, value_type=Choice(vocabulary=SimpleVocabulary(( SimpleTerm(token='Foo', value='foo'), SimpleTerm(token='Bar', value='bar'), SimpleTerm(token='Baz', value='baz'), )), ), default=frozenset([ 'foo', ]))
def test_w_mixed(self): from zope.schema import Text from zope.schema import Bytes from zope.schema import Int from zope.schema import Float from zope.schema import Decimal self.assertEqual(self._callFUT([Text(), 0]), False) self.assertEqual(self._callFUT( [Text(), Bytes(), Int(), Float(), Decimal(), 0]), False)
def test_w_normal_fields(self): from zope.schema import Text from zope.schema import Bytes from zope.schema import Int from zope.schema import Float from zope.schema import Decimal self.assertEqual(self._callFUT(Text()), True) self.assertEqual(self._callFUT(Bytes()), True) self.assertEqual(self._callFUT(Int()), True) self.assertEqual(self._callFUT(Float()), True) self.assertEqual(self._callFUT(Decimal()), True)