<s> import unittest <EOL> from gluon import * <EOL> from gluon . storage import Storage <EOL> from s3 . s3forms import * <EOL> class InlineLinkTests ( unittest . TestCase ) : <EOL> def testInlineLinkValidation ( self ) : <EOL> widget = S3SQLInlineLink ( "<STR_LIT>" , <EOL> field = "<STR_LIT:test>" , <EOL> required = True , <EOL> ) <EOL> widget . alias = "<STR_LIT:default>" <EOL> form = Storage ( vars = Storage ( link_defaultcomponent = [ <NUM_LIT:1> , <NUM_LIT:2> ] ) , <EOL> errors = Storage ( ) , <EOL> ) <EOL> widget . validate ( form ) <EOL> errors = form . errors <EOL> self . assertNotIn ( "<STR_LIT>" , errors ) <EOL> form = Storage ( vars = Storage ( ) , <EOL> errors = Storage ( ) , <EOL> ) <EOL> widget . validate ( form ) <EOL> errors = form . errors <EOL> self . assertIn ( "<STR_LIT>" , errors ) <EOL> msg = "<STR_LIT>" <EOL> widget = S3SQLInlineLink ( "<STR_LIT>" , <EOL> field = "<STR_LIT:test>" , <EOL> required = msg , <EOL> ) <EOL> widget . alias = "<STR_LIT:default>" <EOL> form = Storage ( vars = Storage ( link_defaultcomponent = [ <NUM_LIT:1> , <NUM_LIT:2> ] ) , <EOL> errors = Storage ( ) , <EOL> ) <EOL> widget . validate ( form ) <EOL> errors = form . errors <EOL> self . assertNotIn ( "<STR_LIT>" , errors ) <EOL> form = Storage ( vars = Storage ( ) , <EOL> errors = Storage ( ) , <EOL> ) <EOL> widget . validate ( form ) <EOL> errors = form . errors <EOL> self . assertIn ( "<STR_LIT>" , errors ) <EOL> self . assertEqual ( errors . link_defaultcomponent , msg ) <EOL> def run_suite ( * test_classes ) : <EOL> """<STR_LIT>""" <EOL> loader = unittest . TestLoader ( ) <EOL> suite = unittest . TestSuite ( ) <EOL> for test_class in test_classes : <EOL> tests = loader . loadTestsFromTestCase ( test_class ) <EOL> suite . addTests ( tests ) <EOL> if suite is not None : <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) <EOL> return <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> run_suite ( <EOL> InlineLinkTests , <EOL> ) </s>
