<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> from django import template as django_template <EOL> from google . apputils import basetest <EOL> from googleapis . codegen import language_model <EOL> from googleapis . codegen import template_objects <EOL> class TemplateObjectsTest ( basetest . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TemplateObjectsTest , self ) . setUp ( ) <EOL> self . language_model = language_model . LanguageModel ( class_name_delimiter = '<STR_LIT:|>' ) <EOL> def testFullyQualifiedClassName ( self ) : <EOL> foo = template_objects . CodeObject ( { '<STR_LIT>' : '<STR_LIT>' } , None , <EOL> language_model = self . language_model ) <EOL> foo . _module = template_objects . Module ( '<STR_LIT:test>' , <EOL> language_model = self . language_model ) <EOL> bar = template_objects . CodeObject ( { '<STR_LIT>' : '<STR_LIT>' } , None , parent = foo ) <EOL> baz = template_objects . CodeObject ( { '<STR_LIT>' : '<STR_LIT>' } , None , parent = bar ) <EOL> self . assertEquals ( '<STR_LIT>' , baz . fullClassName ) <EOL> self . assertEquals ( '<STR_LIT>' , baz . RelativeClassName ( baz ) ) <EOL> self . assertEquals ( '<STR_LIT>' , baz . RelativeClassName ( bar ) ) <EOL> self . assertEquals ( '<STR_LIT>' , baz . RelativeClassName ( foo ) ) <EOL> def testModule ( self ) : <EOL> m = template_objects . Module ( '<STR_LIT>' , <EOL> language_model = self . language_model ) <EOL> self . assertEquals ( '<STR_LIT>' , m . name ) <EOL> self . assertEquals ( '<STR_LIT>' , m . path ) <EOL> def testModuleParenting ( self ) : <EOL> m = template_objects . Module ( '<STR_LIT>' , <EOL> language_model = self . language_model ) <EOL> child = template_objects . Module ( '<STR_LIT>' , parent = m ) <EOL> self . assertEquals ( '<STR_LIT>' , child . name ) <EOL> self . assertEquals ( '<STR_LIT>' , child . path ) <EOL> def testModuleNaming ( self ) : <EOL> p = template_objects . Module ( '<STR_LIT>' , <EOL> language_model = self . language_model ) <EOL> foo = template_objects . CodeObject ( { '<STR_LIT>' : '<STR_LIT>' } , None , <EOL> language_model = self . language_model ) <EOL> foo . _module = p <EOL> bar = template_objects . CodeObject ( { '<STR_LIT>' : '<STR_LIT>' } , None , parent = foo ) <EOL> baz = template_objects . CodeObject ( { '<STR_LIT>' : '<STR_LIT>' } , None , parent = bar ) <EOL> self . assertEquals ( '<STR_LIT>' , baz . packageRelativeClassName ) <EOL> self . assertEquals ( '<STR_LIT>' , baz . fullClassName ) <EOL> def testParentPath ( self ) : <EOL> foo = template_objects . CodeObject ( { '<STR_LIT>' : '<STR_LIT>' } , None , <EOL> language_model = self . language_model ) <EOL> bar = template_objects . CodeObject ( { '<STR_LIT>' : '<STR_LIT>' } , None , parent = foo ) <EOL> baz = template_objects . CodeObject ( { '<STR_LIT>' : '<STR_LIT>' } , None , parent = bar ) <EOL> self . assertEquals ( [ '<STR_LIT>' , '<STR_LIT>' ] , baz . parentPath ) <EOL> def _TestRender ( self , source , ctxt , expected ) : <EOL> t = django_template . Template ( source ) <EOL> rendered = t . render ( django_template . Context ( ctxt ) ) <EOL> self . assertEquals ( expected , rendered ) <EOL> def testSimpleUseableInTemplates ( self ) : <EOL> d = dict ( x = <NUM_LIT:1> , y = <NUM_LIT:2> , z = <NUM_LIT:3> ) <EOL> useable = template_objects . UseableInTemplates ( d ) <EOL> t = '<STR_LIT>' <EOL> self . _TestRender ( t , { '<STR_LIT:o>' : useable } , '<STR_LIT>' ) <EOL> def testUseableInTemplatesWithAttributes ( self ) : <EOL> class SubUseable ( template_objects . UseableInTemplates ) : <EOL> def __init__ ( self , def_dict ) : <EOL> super ( SubUseable , self ) . __init__ ( def_dict ) <EOL> self . foo = '<STR_LIT>' <EOL> @ property <EOL> def bar ( self ) : <EOL> return '<STR_LIT>' <EOL> def nougat ( self ) : <EOL> return '<STR_LIT>' <EOL> def codeName ( self ) : <EOL> return '<STR_LIT>' <EOL> def neverCalled ( self ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> d = dict ( x = <NUM_LIT:1> , y = <NUM_LIT:2> , z = <NUM_LIT:3> , codeName = '<STR_LIT>' ) <EOL> useable = SubUseable ( d ) <EOL> t = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . _TestRender ( t , { '<STR_LIT:o>' : useable } , '<STR_LIT>' ) <EOL> d = dict ( neverCalled = '<STR_LIT>' ) <EOL> useable = SubUseable ( d ) <EOL> t = '<STR_LIT>' <EOL> self . _TestRender ( t , { '<STR_LIT:o>' : useable } , '<STR_LIT>' ) <EOL> class ConstantTest ( basetest . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( ConstantTest , self ) . setUp ( ) <EOL> class MyLanguageModel ( language_model . LanguageModel ) : <EOL> constant_policy = language_model . NamingPolicy ( <EOL> case_transform = language_model . UPPER_CAMEL_CASE , separator = '<STR_LIT:|>' ) <EOL> self . language_model = MyLanguageModel ( ) <EOL> def testConstantNameFixer ( self ) : <EOL> c = template_objects . Constant ( '<STR_LIT>' , <EOL> language_model = self . language_model ) <EOL> self . assertEquals ( '<STR_LIT>' , c . value ) <EOL> self . assertEquals ( '<STR_LIT>' , c . name ) <EOL> self . assertEquals ( '<STR_LIT>' , c . constantName ) <EOL> self . assertIsNone ( c . description ) <EOL> c = template_objects . Constant ( '<STR_LIT>' , language_model = self . language_model ) <EOL> self . assertEquals ( '<STR_LIT>' , c . value ) <EOL> self . assertEquals ( '<STR_LIT>' , c . name ) <EOL> self . assertEquals ( '<STR_LIT>' , c . constantName ) <EOL> c = template_objects . Constant ( <NUM_LIT> , language_model = self . language_model ) <EOL> self . assertEquals ( '<STR_LIT>' , c . value ) <EOL> self . assertEquals ( '<STR_LIT>' , c . name ) <EOL> self . assertEquals ( '<STR_LIT>' , c . constantName ) <EOL> c = template_objects . Constant ( <NUM_LIT> , name = '<STR_LIT>' , <EOL> language_model = self . language_model ) <EOL> self . assertEquals ( '<STR_LIT>' , c . value ) <EOL> self . assertEquals ( '<STR_LIT>' , c . name ) <EOL> self . assertEquals ( '<STR_LIT>' , c . constantName ) <EOL> c = template_objects . Constant ( '<STR_LIT>' , language_model = self . language_model ) <EOL> self . assertEquals ( '<STR_LIT>' , c . value ) <EOL> self . assertEquals ( '<STR_LIT>' , c . name ) <EOL> self . assertEquals ( '<STR_LIT>' , c . constantName ) <EOL> c = template_objects . Constant ( '<STR_LIT>' , language_model = self . language_model ) <EOL> self . assertEquals ( '<STR_LIT>' , c . value ) <EOL> self . assertEquals ( '<STR_LIT:foo>' , c . name ) <EOL> self . assertEquals ( '<STR_LIT>' , c . constantName ) <EOL> c = template_objects . Constant ( '<STR_LIT>' , language_model = self . language_model ) <EOL> self . assertEquals ( '<STR_LIT>' , c . value ) <EOL> self . assertEquals ( '<STR_LIT>' , c . name ) <EOL> self . assertEquals ( '<STR_LIT>' , c . constantName ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> basetest . main ( ) </s>
