<s> import os <EOL> import shutil <EOL> from cactus . tests import SiteTestCase <EOL> from cactus . utils . filesystem import fileList <EOL> from cactus . utils . url import path_to_url <EOL> class TestSite ( SiteTestCase ) : <EOL> def testBuild ( self ) : <EOL> """<STR_LIT>""" <EOL> self . site . build ( ) <EOL> self . assertEqual ( os . path . exists ( os . path . join ( self . path , '<STR_LIT>' ) ) , False ) <EOL> self . assertEqual ( <EOL> sorted ( [ path_to_url ( path ) for path in fileList ( os . path . join ( self . path , '<STR_LIT>' ) , relative = True ) ] ) , <EOL> sorted ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> self . site . get_url_for_static ( '<STR_LIT>' ) [ <NUM_LIT:1> : ] , <EOL> self . site . get_url_for_static ( '<STR_LIT>' ) [ <NUM_LIT:1> : ] , <EOL> self . site . get_url_for_static ( '<STR_LIT>' ) [ <NUM_LIT:1> : ] , <EOL> ] ) ) <EOL> def testRenderPage ( self ) : <EOL> """<STR_LIT>""" <EOL> shutil . copy ( <EOL> os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:data>' , "<STR_LIT>" ) , <EOL> os . path . join ( self . path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> ) <EOL> self . site . build ( ) <EOL> with open ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:data>' , '<STR_LIT>' ) , "<STR_LIT>" ) as expected : <EOL> with open ( os . path . join ( self . path , '<STR_LIT>' , '<STR_LIT>' ) , "<STR_LIT>" ) as obtained : <EOL> self . assertEqual ( expected . read ( ) , obtained . read ( ) ) <EOL> def testPageContext ( self ) : <EOL> """<STR_LIT>""" <EOL> shutil . copy ( <EOL> os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:data>' , "<STR_LIT>" ) , <EOL> os . path . join ( self . path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> ) <EOL> self . site . build ( ) <EOL> with open ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:data>' , '<STR_LIT>' ) , "<STR_LIT>" ) as expected : <EOL> with open ( os . path . join ( self . path , '<STR_LIT>' , '<STR_LIT>' ) , "<STR_LIT>" ) as obtained : <EOL> self . assertEqual ( expected . read ( ) , obtained . read ( ) ) <EOL> def test_html_only_context ( self ) : <EOL> """<STR_LIT>""" <EOL> robots_txt = '<STR_LIT>' <EOL> with open ( os . path . join ( self . site . path , '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT:w>' ) as f : <EOL> f . write ( robots_txt ) <EOL> self . site . build ( ) <EOL> with open ( os . path . join ( self . site . build_path , '<STR_LIT>' ) , '<STR_LIT>' ) as f : <EOL> self . assertEquals ( robots_txt , f . read ( ) ) <EOL> def testStaticLoader ( self ) : <EOL> """<STR_LIT>""" <EOL> static = '<STR_LIT>' <EOL> page = "<STR_LIT>" % static <EOL> with open ( os . path . join ( self . path , '<STR_LIT>' , '<STR_LIT>' ) , "<STR_LIT:w>" ) as dst : <EOL> dst . write ( page ) <EOL> self . site . build ( ) <EOL> with open ( os . path . join ( self . path , '<STR_LIT>' , '<STR_LIT>' ) , "<STR_LIT>" ) as obtained : <EOL> self . assertEqual ( self . site . get_url_for_static ( static ) , obtained . read ( ) ) <EOL> def test_current_page ( self ) : <EOL> """<STR_LIT>""" <EOL> page = '<STR_LIT>' <EOL> content = "<STR_LIT>" % page <EOL> other = '<STR_LIT>' <EOL> with open ( os . path . join ( self . path , '<STR_LIT>' , page ) , '<STR_LIT:w>' ) as f : <EOL> f . write ( content ) <EOL> with open ( os . path . join ( self . path , '<STR_LIT>' , other ) , '<STR_LIT:w>' ) as f : <EOL> f . write ( content ) <EOL> self . site . build ( ) <EOL> with open ( os . path . join ( self . path , '<STR_LIT>' , page ) , '<STR_LIT>' ) as f : <EOL> self . assertEqual ( '<STR_LIT:True>' , f . read ( ) ) <EOL> with open ( os . path . join ( self . path , '<STR_LIT>' , other ) , '<STR_LIT>' ) as f : <EOL> self . assertEqual ( '<STR_LIT:False>' , f . read ( ) ) </s>
