#!env/bin/python import os, sys sys.path.append( os.path.abspath( "." ) ) from botanjs.service.jwork import app, JWork from botanjs.config import Config as config SiteRoot = os.path.abspath( "." ) # Setting the SiteRoot for config config["Paths"]["SiteRoot"] = SiteRoot jsCache = config["Paths"]["Cache"] jsRoot = config["BotanJS"]["SrcDir"] bmap = os.path.join( jsCache, "botanjs", "bmap.xml" ) app.conf.update( broker_url = config["BotanJS"]["CeleryBroker"] ) JWork.buildClassMap.delay( jsRoot, bmap ) from botanjs.service.jclassresv import BotanClassResolver as JCResv import unittest class TestStringMethods( unittest.TestCase ): # Run each twice to test the cache capabilities def test_ojscall( self ): srv = JCResv( JWork, jsRoot, bmap, jsCache ) for _ in range(0,2): s = srv.getAPI( "System", mode = "rjs" ) if not ( "BotanJS.define( \"System\" );" in s ): print( "A---------------------" ) print( s ) print( "B---------------------" ) self.assertTrue( False) def test_import( self ): srv = JCResv( JWork, jsRoot, bmap, jsCache ) for _ in range(0,2): s = srv.getAPI( "System.Policy", mode = "rjs" ) self.assertTrue( "BotanJS.define( \"System.Policy\" );" in s ) self.assertTrue( "BotanJS.define( \"System.Global\" );" in s ) def test_cssInheritance( self ): srv = JCResv( JWork, jsRoot, bmap, jsCache ) for _ in range(0,2): s = srv.getAPI( "System", mode = "rcss" ) self.assertTrue( "/* @ */" in s ) # def test_jsZCalls( self ): # srv = JCResv( JWork, jsRoot, bmap, jsCache ) # for _ in range(0,2): # s = srv.getAPI( "eJx1zsEKgzAQBNAfKvsPaaj0YE/6A4tuJbDJlM2K9O/rpcUKOQ6PYSZUN9DgbE9WpZtKluJ0F57FLuFfe35jdXpwKp1xlrN/2x3gv/ZVsVBEfqHsVmmQyRNKQ6Nhm0dejtyYPVowT5PKHl2qN36PGyJ0zeUDs1BbKA==", mode = "css" ) # print( s ) if __name__ == '__main__': unittest.main()