<s> import base64 <EOL> from nova . api import validator <EOL> from nova import test <EOL> class ValidatorTestCase ( test . NoDBTestCase ) : <EOL> def test_validate ( self ) : <EOL> fixture = { <EOL> '<STR_LIT:foo>' : lambda val : val is True <EOL> } <EOL> self . assertTrue ( <EOL> validator . validate ( { '<STR_LIT:foo>' : True } , fixture ) ) <EOL> self . assertFalse ( <EOL> validator . validate ( { '<STR_LIT:foo>' : False } , fixture ) ) <EOL> def test_only_tests_intersect ( self ) : <EOL> """<STR_LIT>""" <EOL> fixture = { <EOL> '<STR_LIT:foo>' : lambda val : True , <EOL> '<STR_LIT:bar>' : lambda val : True <EOL> } <EOL> self . assertTrue ( <EOL> validator . validate ( { '<STR_LIT:foo>' : True } , fixture ) ) <EOL> self . assertTrue ( <EOL> validator . validate ( { '<STR_LIT:foo>' : True , '<STR_LIT:bar>' : True } , fixture ) ) <EOL> self . assertTrue ( <EOL> validator . validate ( { '<STR_LIT:foo>' : True , '<STR_LIT:bar>' : True , '<STR_LIT>' : True } , <EOL> fixture ) ) <EOL> def test_validate_str ( self ) : <EOL> self . assertTrue ( validator . validate_str ( ) ( '<STR_LIT:foo>' ) ) <EOL> self . assertFalse ( validator . validate_str ( ) ( <NUM_LIT:1> ) ) <EOL> self . assertTrue ( validator . validate_str ( <NUM_LIT:4> ) ( '<STR_LIT:foo>' ) ) <EOL> self . assertFalse ( validator . validate_str ( <NUM_LIT:2> ) ( '<STR_LIT:foo>' ) ) <EOL> self . assertFalse ( validator . validate_str ( ) ( None ) ) <EOL> self . assertTrue ( validator . validate_str ( ) ( u'<STR_LIT:foo>' ) ) <EOL> def test_validate_int ( self ) : <EOL> self . assertTrue ( validator . validate_int ( ) ( <NUM_LIT:1> ) ) <EOL> self . assertFalse ( validator . validate_int ( ) ( '<STR_LIT:foo>' ) ) <EOL> self . assertTrue ( validator . validate_int ( <NUM_LIT:100> ) ( <NUM_LIT:1> ) ) <EOL> self . assertFalse ( validator . validate_int ( <NUM_LIT:4> ) ( <NUM_LIT:5> ) ) <EOL> self . assertFalse ( validator . validate_int ( ) ( None ) ) <EOL> def test_validate_url_path ( self ) : <EOL> self . assertTrue ( validator . validate_url_path ( '<STR_LIT>' ) ) <EOL> self . assertFalse ( validator . validate_url_path ( '<STR_LIT>' ) ) <EOL> self . assertFalse ( <EOL> validator . validate_url_path ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertFalse ( validator . validate_url_path ( None ) ) <EOL> self . assertFalse ( validator . validate_url_path ( <NUM_LIT> ) ) <EOL> def test_validate_image_path ( self ) : <EOL> self . assertTrue ( validator . validate_image_path ( '<STR_LIT>' ) ) <EOL> self . assertFalse ( validator . validate_image_path ( '<STR_LIT>' ) ) <EOL> self . assertFalse ( validator . validate_image_path ( '<STR_LIT:path>' ) ) <EOL> def test_validate_user_data ( self ) : <EOL> fixture = base64 . b64encode ( '<STR_LIT:foo>' ) <EOL> self . assertTrue ( validator . validate_user_data ( fixture ) ) <EOL> self . assertFalse ( validator . validate_user_data ( False ) ) <EOL> self . assertFalse ( validator . validate_user_data ( '<STR_LIT>' ) ) </s>
