<s> """<STR_LIT>""" <EOL> from google . apputils import basetest <EOL> from googleapis . codegen import data_types <EOL> from googleapis . codegen import data_value <EOL> from googleapis . codegen import language_model <EOL> from googleapis . codegen import schema <EOL> from django import template as django_template <EOL> class DataValueTest ( basetest . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( DataValueTest , self ) . setUp ( ) <EOL> self . language_model = language_model . LanguageModel ( class_name_delimiter = '<STR_LIT:|>' ) <EOL> def testDataValue ( self ) : <EOL> foo_def_dict = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT:string>' , <EOL> } <EOL> prototype = data_types . DataType ( <EOL> foo_def_dict , None , language_model = self . language_model ) <EOL> dv = data_value . DataValue ( <NUM_LIT:3> , prototype ) <EOL> self . assertEqual ( <NUM_LIT:3> , dv . value ) <EOL> self . assertEqual ( prototype , dv . data_type ) <EOL> self . assertEqual ( { } , dv . metadata ) <EOL> self . assertEqual ( '<STR_LIT>' , dv . code_type ) <EOL> dv . metadata [ '<STR_LIT:foo>' ] = '<STR_LIT:bar>' <EOL> self . assertEqual ( { '<STR_LIT:foo>' : '<STR_LIT:bar>' } , dv . metadata ) <EOL> dv . SetValue ( '<STR_LIT>' ) <EOL> self . assertEqual ( dv . value , '<STR_LIT>' ) <EOL> self . assertEqual ( self . language_model , dv . GetLanguageModel ( ) ) <EOL> other_language_model = language_model . LanguageModel ( <EOL> class_name_delimiter = '<STR_LIT:+>' ) <EOL> dv . SetLanguageModel ( other_language_model ) <EOL> self . assertEqual ( other_language_model , dv . GetLanguageModel ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , dv . code_type ) <EOL> dv = data_value . DataValue ( object , prototype ) <EOL> self . assertEqual ( dv . value , object ) <EOL> bar_def_dict = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT:string>' , <EOL> } <EOL> class MockApi ( object ) : <EOL> def __init__ ( self ) : <EOL> self . model_module = None <EOL> def SetSchema ( self , s ) : <EOL> self . schema = s <EOL> def SetSchemaRef ( self , schema_ref ) : <EOL> self . schema_ref = schema_ref <EOL> def ToClassName ( self , name , element , element_type ) : <EOL> return name <EOL> def SchemaByName ( self , schema_name ) : <EOL> return self . schema <EOL> def DataTypeFromJson ( self , unused_def_dict , tentative_class_name , <EOL> parent = None , wire_name = None ) : <EOL> return self . schema_ref <EOL> def NestedClassNameForProperty ( self , name , owning_schema ) : <EOL> return '<STR_LIT>' % ( owning_schema . class_name , name ) <EOL> mock_api = MockApi ( ) <EOL> bar_schema = schema . Schema ( mock_api , '<STR_LIT>' , bar_def_dict ) <EOL> mock_api . SetSchema ( bar_schema ) <EOL> schema_ref = data_types . SchemaReference ( '<STR_LIT>' , mock_api ) <EOL> mock_api . SetSchemaRef ( schema_ref ) <EOL> prototype = schema . Property ( mock_api , schema_ref , '<STR_LIT>' , foo_def_dict ) <EOL> dv = data_value . DataValue ( '<STR_LIT:3>' , prototype ) <EOL> self . assertEqual ( mock_api . schema , dv . data_type ) <EOL> class DataValueRenderingTest ( basetest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def _GetContext ( self , data = None ) : <EOL> return django_template . Context ( data or { } ) <EOL> def testDataContextNode ( self ) : <EOL> lang_model = language_model . LanguageModel ( '<STR_LIT:|>' ) <EOL> foo_def_dict = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT:string>' , <EOL> } <EOL> prototype = data_types . DataType ( <EOL> foo_def_dict , None , language_model = lang_model ) <EOL> dv = data_value . DataValue ( '<STR_LIT>' , prototype ) <EOL> source = '<STR_LIT>' <EOL> template = django_template . Template ( source ) <EOL> context = self . _GetContext ( { '<STR_LIT:data>' : dv } ) <EOL> self . assertEquals ( '<STR_LIT>' , template . render ( context ) ) <EOL> context = self . _GetContext ( { '<STR_LIT:data>' : '<STR_LIT:foo>' } ) <EOL> self . assertRaises ( <EOL> django_template . TemplateSyntaxError , template . render , context ) <EOL> bar_def_dict = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> } <EOL> prototype = data_types . DataType ( <EOL> bar_def_dict , None , language_model = lang_model ) <EOL> dv = data_value . DataValue ( '<STR_LIT>' , prototype ) <EOL> context = self . _GetContext ( { '<STR_LIT:data>' : dv } ) <EOL> self . assertRaises ( <EOL> django_template . TemplateSyntaxError , template . render , context ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> basetest . main ( ) </s>
