def test_default_django_field_args( self ): logger.debug( "\n" ) self.form.fields[ 'name' ] = zRadioSelect( **{ 'required' : True , 'label' : 'stupid is' , 'initial' : True, } ) 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.attrs.get( 'checked', None ), 'checked' ) logger.debug( "\n==================================================\n" )
def test_attribute_override( self ): logger.debug( "\n" ) self.form.fields[ 'name' ] = zRadioSelect( **{ 'id' : 'tinker_bot' , 'class' : 'real cool', 'disabled' : True , 'readonly' : True , } ) rendering = self.form.as_p() logger.debug( "[ RENDERED FORM ]: %s" % rendering ) soup = BS( rendering ) tag, tag1 = soup.find_all( 'input' ) logger.debug( "[ TAG ATTRS ]: %s" % tag.attrs ) # assert lots self.assertEqual( tag.get( 'id', None ), 'tinker_bot_0' ) self.assertEqual( tag1.get( 'id', None ), 'tinker_bot_1' ) self.assertEqual( tag.get( 'class', None ), [ 'real', 'cool' ] ) self.assertEqual( tag.get( 'disabled', None ), 'disabled' ) self.assertEqual( tag.get( 'readonly', None ), 'readonly' ) logger.debug( "\n==================================================\n" )