def test_formbase_with_field_widget_instance_no_id(self): class UserForm(FormBase): __entity__ = User user_name = Field(MyTextField()) user_form = UserForm(session) widget = user_form.__widget__ assert widget_is_type(widget_children(widget)['user_name'], MyTextField)
def test_formbase_with_field_widget_instance_no_id(self): class UserForm(FormBase): __entity__ = User user_name = Field(MyTextField()) user_form = UserForm(session) widget = user_form.__widget__ assert widget_is_type( widget_children(widget)['user_name'], MyTextField)
def test_custom_field(self): class UserView(ViewBase): __entity__ = User __metadata_type__ = DummyMetadata __field_widgets__ = {'password': TextField(id='password')} user_view = UserView() widget = user_view.__widget__ child = widget_children(widget)['password'] assert widget_is_type(child, TextField), child.__class__
def test_hidden_fields(self): class UserView(ViewBase): __entity__ = User __metadata_type__ = DummyMetadata __hide_fields__ = ['password'] user_view = UserView() widget = user_view.__widget__ child = widget_children(widget)['password'] assert widget_is_type(child, HiddenField), child.__class__
def test_hidden_fields(self): class UserView(ViewBase): __entity__ = User __metadata_type__ = DummyMetadata __hide_fields__ = ['password'] user_view = UserView() widget = user_view.__widget__ child = widget_children(widget)['password'] assert widget_is_type(child, HiddenField), child.__class__
def test_custom_with_none(self): class UserView(ViewBase): __entity__ = User __metadata_type__ = DummyMetadata __add_fields__ = {'password': None} user_view = UserView() widget = user_view.__widget__ child = widget_children(widget)['password'] assert widget_is_type(child, Widget), str(child.__class__)
def test_custom_field(self): class UserView(ViewBase): __entity__ = User __metadata_type__ = DummyMetadata __field_widgets__ = {'password':TextField(id='password')} user_view = UserView() widget = user_view.__widget__ child = widget_children(widget)['password'] assert widget_is_type(child, TextField), child.__class__
def test_custom_with_none(self): class UserView(ViewBase): __entity__ = User __metadata_type__ = DummyMetadata __add_fields__ = {'password':None} user_view = UserView() widget = user_view.__widget__ child = widget_children(widget)['password'] assert widget_is_type(child, Widget), str(child.__class__)
def test_formbase_with_field_widget_and_validator_instance(self): class UserForm(FormBase): __entity__ = User user_name = Field(MyTextField, OpenId) user_form = UserForm(session) widget = user_form.__widget__ assert widget_is_type(widget_children(widget)['user_name'], MyTextField) try: widget.validate({'user_name':'something'}) except Invalid as e: msg = form_error_message(e) assert '"something" is not a valid OpenId (it is neither an URL nor an XRI)' in msg, msg
def test_formbase_with_field_widget_and_validator_instance(self): class UserForm(FormBase): __entity__ = User user_name = Field(MyTextField, OpenId) user_form = UserForm(session) widget = user_form.__widget__ assert widget_is_type( widget_children(widget)['user_name'], MyTextField) try: widget.validate({'user_name': 'something', 'created': ''}) except Invalid as e: msg = form_error_message(e) assert '"something" is not a valid OpenId (it is neither an URL nor an XRI)' in msg, msg
def test__widget__(self): if not hasattr(Widget, 'req'): eq_(None, self.base.__widget__()) else: assert widget_is_type(self.base.__widget__(), Widget)
def test__widget__(self): if not hasattr(Widget, 'req'): eq_(None, self.base.__widget__()) else: assert widget_is_type(self.base.__widget__(), Widget)