def test_eval_hidden_input( self ): logger.debug( "\n========================\n" ) self.form.fields[ 'name' ] = zTextInput( **{ 'widget' : eval('getattr( forms, "HiddenInput" )()') , } ) rendering = self.form.as_p() logger.debug( "[ RENDERED FORM ]: %s\n" % rendering ) soup = BS( rendering ) tag = soup.input logger.debug( "[ TAG ATTRS ]: %s\n" % tag.attrs ) self.assertEqual( tag[ 'type' ], 'hidden' ) logger.debug( "\n==================================================\n" )
def test_default_django_field_args( self ): logger.debug( "\n" ) self.form.fields[ 'name' ] = zTextInput( **{ 'required' : True , 'label' : 'stupid is' , 'initial' : 'stupid does' , } ) rendering = self.form.as_p() logger.debug( "[ RENDERED FORM ]: %s\n" % rendering ) soup = BS( rendering ) input_tag = soup.input logger.debug( "[ INPUT TAG ATTRS ]: %s\n" % input_tag.attrs ) label_tag = soup.label logger.debug( "[ LABEL TAG ATTRS ]: %s\n" % label_tag.attrs ) # assert lots self.assertIsNotNone( input_tag.attrs.get( 'required', None ) ) self.assertEqual( label_tag.get_text(), 'stupid is:' ) self.assertEqual( input_tag[ 'value' ], 'stupid does' ) logger.debug( "\n==================================================\n" )
def test_attribute_override( self ): logger.debug( "\n" ) self.form.fields[ 'name' ] = zTextInput( **{ 'pattern' : '[0-9]' , 'id' : 'tinker_bot' , 'class' : 'real cool', 'disabled' : True , 'readonly' : True , 'placeholder' : 'a_placeholder', } ) rendering = self.form.as_p() logger.debug( "[ RENDERED FORM ]: %s" % rendering ) soup = BS( rendering ) tag = soup.input logger.debug( "[ TAG ATTRS ]: %s" % tag.attrs ) # assert lots self.assertEqual( tag.get( 'data-pattern', None ), '[0-9]' ) self.assertEqual( tag.get( 'id', None ), 'tinker_bot' ) self.assertEqual( tag.get( 'class', None ), [ 'real', 'cool' ] ) self.assertEqual( tag.get( 'disabled', None ), 'disabled' ) self.assertEqual( tag.get( 'readonly', None ), 'readonly' ) self.assertEqual( tag.get( 'placeholder', None ), 'a_placeholder' ) logger.debug( "\n==================================================\n" )