<s> import sys , os , unittest , logging , tempfile <EOL> jasyroot = os . path . normpath ( os . path . join ( os . path . abspath ( sys . argv [ <NUM_LIT:0> ] ) , os . pardir , os . pardir , os . pardir ) ) <EOL> sys . path . insert ( <NUM_LIT:0> , jasyroot ) <EOL> import jasy . core . Project as Project <EOL> class Tests ( unittest . TestCase ) : <EOL> def writeFile ( self , path , fileName , content ) : <EOL> handle = open ( os . path . join ( path , fileName ) , mode = "<STR_LIT:w>" , encoding = "<STR_LIT:utf-8>" ) <EOL> handle . write ( content ) <EOL> handle . close ( ) <EOL> def readFile ( self , path , fileName ) : <EOL> return open ( os . path . join ( path , fileName ) , mode = "<STR_LIT:r>" , encoding = "<STR_LIT:utf-8>" ) . read ( ) <EOL> def createjpyaml ( self , path ) : <EOL> self . writeFile ( path , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> def createjpyaml_withContent ( self , path ) : <EOL> self . writeFile ( path , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> def createCaseOne ( self ) : <EOL> path = os . path . join ( tempfile . TemporaryDirectory ( ) . name , "<STR_LIT>" ) <EOL> os . makedirs ( path ) <EOL> def createFolders ( ) : <EOL> os . makedirs ( os . path . join ( path , "<STR_LIT>" ) ) <EOL> def createSampleClasses ( ) : <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT>" ) , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT>" ) , "<STR_LIT>" , "<STR_LIT:;>" ) <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT>" ) , "<STR_LIT>" , "<STR_LIT:;>" ) <EOL> def createSampleAssets ( ) : <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT>" ) , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> createFolders ( ) <EOL> self . createjpyaml_withContent ( path ) <EOL> createSampleClasses ( ) <EOL> createSampleAssets ( ) <EOL> return Project . getProjectFromPath ( path ) <EOL> def createCaseTwo ( self ) : <EOL> path = os . path . join ( tempfile . TemporaryDirectory ( ) . name , "<STR_LIT>" ) <EOL> os . makedirs ( path ) <EOL> def createFolders ( ) : <EOL> os . makedirs ( os . path . join ( path , "<STR_LIT:source>" ) ) <EOL> os . makedirs ( os . path . join ( os . path . join ( path , "<STR_LIT:source>" ) , "<STR_LIT:class>" ) ) <EOL> os . makedirs ( os . path . join ( os . path . join ( path , "<STR_LIT:source>" ) , "<STR_LIT>" ) ) <EOL> os . makedirs ( os . path . join ( os . path . join ( path , "<STR_LIT:source>" ) , "<STR_LIT>" ) ) <EOL> def createSampleClasses ( ) : <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT:source>" ) , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> self . writeFile ( os . path . join ( os . path . join ( path , "<STR_LIT:source>" ) , "<STR_LIT:class>" ) , "<STR_LIT>" , "<STR_LIT:;>" ) <EOL> def createSampleAssets ( ) : <EOL> self . writeFile ( os . path . join ( os . path . join ( path , "<STR_LIT:source>" ) , "<STR_LIT>" ) , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> def createSampleTranslations ( ) : <EOL> self . writeFile ( os . path . join ( os . path . join ( path , "<STR_LIT:source>" ) , "<STR_LIT>" ) , "<STR_LIT>" , "<STR_LIT:U+0020>" ) <EOL> createFolders ( ) <EOL> self . createjpyaml ( path ) <EOL> createSampleClasses ( ) <EOL> createSampleAssets ( ) <EOL> createSampleTranslations ( ) <EOL> return Project . getProjectFromPath ( path ) <EOL> def createCaseThree ( self ) : <EOL> path = os . path . join ( tempfile . TemporaryDirectory ( ) . name , "<STR_LIT>" ) <EOL> os . makedirs ( path ) <EOL> def createFolders ( ) : <EOL> os . makedirs ( os . path . join ( path , "<STR_LIT:src>" ) ) <EOL> def createSampleClasses ( ) : <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT:src>" ) , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT:src>" ) , "<STR_LIT>" , "<STR_LIT:;>" ) <EOL> def createSampleAssets ( ) : <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT:src>" ) , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> createFolders ( ) <EOL> self . createjpyaml ( path ) <EOL> createSampleClasses ( ) <EOL> createSampleAssets ( ) <EOL> return Project . getProjectFromPath ( path ) <EOL> def createCaseFour ( self ) : <EOL> path = os . path . join ( tempfile . TemporaryDirectory ( ) . name , "<STR_LIT>" ) <EOL> os . makedirs ( path ) <EOL> def createFolders ( ) : <EOL> os . makedirs ( os . path . join ( path , "<STR_LIT:class>" ) ) <EOL> os . makedirs ( os . path . join ( path , "<STR_LIT>" ) ) <EOL> os . makedirs ( os . path . join ( path , "<STR_LIT>" ) ) <EOL> def createSampleClasses ( ) : <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT:class>" ) , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT:class>" ) , "<STR_LIT>" , "<STR_LIT:;>" ) <EOL> def createSampleAssets ( ) : <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT>" ) , "<STR_LIT>" , """<STR_LIT>""" ) <EOL> def createSampleTranslations ( ) : <EOL> self . writeFile ( os . path . join ( path , "<STR_LIT>" ) , "<STR_LIT>" , "<STR_LIT:U+0020>" ) <EOL> createFolders ( ) <EOL> self . createjpyaml ( path ) <EOL> createSampleClasses ( ) <EOL> createSampleAssets ( ) <EOL> createSampleTranslations ( ) <EOL> return Project . getProjectFromPath ( path ) <EOL> def getProjects ( self ) : <EOL> return [ self . createCaseOne ( ) , self . createCaseTwo ( ) , self . createCaseThree ( ) , self . createCaseFour ( ) ] <EOL> def test_get_project ( self ) : <EOL> for project in self . getProjects ( ) : <EOL> self . assertEqual ( project . getName ( ) , "<STR_LIT>" ) <EOL> def test_get_name_from_path ( self ) : <EOL> for project in self . getProjects ( ) : <EOL> self . assertEqual ( Project . getProjectNameFromPath ( project . getPath ( ) ) , "<STR_LIT>" ) <EOL> def test_scan ( self ) : <EOL> for project in self . getProjects ( ) : <EOL> project . scan ( ) <EOL> self . assertEqual ( project . scanned , True ) <EOL> def test_has_requires ( self ) : <EOL> for project in self . getProjects ( ) : <EOL> self . assertEqual ( project . hasRequires ( ) , False ) <EOL> def test_fields ( self ) : <EOL> for project in self . getProjects ( ) : <EOL> self . assertEqual ( project . getFields ( ) , { } ) <EOL> def test_get_class_by_name ( self ) : <EOL> for project in self . getProjects ( ) : <EOL> self . assertEqual ( project . getClassByName ( "<STR_LIT>" ) , project . getClasses ( ) [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( type ( project . getClassByName ( "<STR_LIT>" ) ) . __name__ , "<STR_LIT>" ) <EOL> def test_assets ( self ) : <EOL> for project in self . getProjects ( ) : <EOL> self . assertEqual ( type ( project . getAssets ( ) [ "<STR_LIT>" ] ) . __name__ , "<STR_LIT>" ) <EOL> def test_translations ( self ) : <EOL> for project in [ self . createCaseTwo ( ) , self . createCaseFour ( ) ] : <EOL> self . assertEqual ( type ( project . getTranslations ( ) [ "<STR_LIT>" ] ) . __name__ , "<STR_LIT>" ) <EOL> def test_manual_class_fusion ( self ) : <EOL> self . assertEqual ( self . createCaseOne ( ) . getClassByName ( "<STR_LIT>" ) . getText ( ) , "<STR_LIT>" ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> logging . getLogger ( ) . setLevel ( logging . ERROR ) <EOL> suite = unittest . TestLoader ( ) . loadTestsFromTestCase ( Tests ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) </s>
