本文整理匯總了Python中plone.dexterity.browser.add.DefaultAddForm.fields方法的典型用法代碼示例。如果您正苦於以下問題:Python DefaultAddForm.fields方法的具體用法?Python DefaultAddForm.fields怎麽用?Python DefaultAddForm.fields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類plone.dexterity.browser.add.DefaultAddForm
的用法示例。
在下文中一共展示了DefaultAddForm.fields方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_form_create
# 需要導入模塊: from plone.dexterity.browser.add import DefaultAddForm [as 別名]
# 或者: from plone.dexterity.browser.add.DefaultAddForm import fields [as 別名]
def test_form_create(self):
# Context and request
context = Container(u"container")
request = TestRequest()
# FTI - returns dummy factory name
fti_mock = DexterityFTI(u"testtype")
fti_mock.factory = u'testfactory'
self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
# The form we're testing
form = DefaultAddForm(context, request)
form.portal_type = u"testtype"
class ISchema(Interface):
foo = schema.TextLine()
form.fields = Fields(ISchema)
# createObject and applyChanges
obj_dummy = Item(id="dummy")
alsoProvides(obj_dummy, ISchema)
data_dummy = {u"foo": u"bar"}
from zope.component import createObject
self.patch_global(createObject, return_value=obj_dummy)
provideAdapter(AttributeField)
self.assertEqual(obj_dummy, form.create(data_dummy))
self.assertEqual("testtype", obj_dummy.portal_type)