<s> import subprocess <EOL> import mechanize <EOL> import cookielib <EOL> import unittest <EOL> import shutil <EOL> import os <EOL> from flask import Flask <EOL> from flask . ext . testing import LiveServerTestCase <EOL> from lwp . app import app <EOL> from lwp . utils import connect_db <EOL> class TestWebBrowser ( LiveServerTestCase ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> shutil . copyfile ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> shutil . rmtree ( '<STR_LIT>' , ignore_errors = True ) <EOL> cj = cookielib . LWPCookieJar ( ) <EOL> cls . br = mechanize . Browser ( ) <EOL> cls . br . set_cookiejar ( cj ) <EOL> def create_app ( self ) : <EOL> app . config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> return app <EOL> def test_00_login ( self ) : <EOL> """<STR_LIT>""" <EOL> self . client = app . test_client ( ) <EOL> self . client . post ( '<STR_LIT>' , data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } , follow_redirects = True ) <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> resp = self . br . response ( ) <EOL> assert self . br . viewing_html ( ) <EOL> self . br . select_form ( name = "<STR_LIT>" ) <EOL> self . br [ '<STR_LIT:username>' ] = "<STR_LIT>" <EOL> self . br [ '<STR_LIT:password>' ] = "<STR_LIT>" <EOL> resp = self . br . submit ( ) <EOL> assert '<STR_LIT>' in resp . geturl ( ) <EOL> def test_01_home_render ( self ) : <EOL> """<STR_LIT>""" <EOL> subprocess . check_output ( '<STR_LIT>' , shell = True ) <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> resp = self . br . response ( ) . read ( ) <EOL> assert self . br . viewing_html ( ) <EOL> assert '<STR_LIT>' in resp <EOL> assert '<STR_LIT>' in resp <EOL> def test_02_start_container ( self ) : <EOL> """<STR_LIT>""" <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> resp = self . br . response ( ) . read ( ) <EOL> assert self . br . viewing_html ( ) <EOL> assert '<STR_LIT>' in resp <EOL> assert '<STR_LIT>' in resp <EOL> def test_03_freeze_container ( self ) : <EOL> """<STR_LIT>""" <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> resp = self . br . response ( ) . read ( ) <EOL> assert self . br . viewing_html ( ) <EOL> assert '<STR_LIT>' in resp <EOL> assert '<STR_LIT>' in resp <EOL> def test_04_unfreeze_container ( self ) : <EOL> """<STR_LIT>""" <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> resp = self . br . response ( ) . read ( ) <EOL> assert self . br . viewing_html ( ) <EOL> assert '<STR_LIT>' in resp <EOL> assert '<STR_LIT>' in resp <EOL> def test_05_stop_container ( self ) : <EOL> """<STR_LIT>""" <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> resp = self . br . response ( ) . read ( ) <EOL> assert self . br . viewing_html ( ) <EOL> assert '<STR_LIT>' in resp <EOL> assert '<STR_LIT>' in resp <EOL> def test_06_refresh_info ( self ) : <EOL> """<STR_LIT>""" <EOL> self . br . open ( self . get_server_url ( ) + '<STR_LIT>' ) <EOL> j_data = self . br . response ( ) . read ( ) <EOL> assert '<STR_LIT>' in j_data <EOL> assert '<STR_LIT>' in j_data <EOL> assert '<STR_LIT>' in j_data <EOL> def test_07_create_container ( self ) : <EOL> """<STR_LIT>""" <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> self . br . select_form ( name = "<STR_LIT>" ) <EOL> self . br [ '<STR_LIT:name>' ] = "<STR_LIT>" <EOL> resp = self . br . submit ( ) <EOL> assert '<STR_LIT>' in resp . geturl ( ) <EOL> assert '<STR_LIT>' in resp . read ( ) <EOL> def test_08_create_token ( self ) : <EOL> """<STR_LIT>""" <EOL> self . br . open ( self . get_server_url ( ) + "<STR_LIT>" ) <EOL> self . br . select_form ( name = "<STR_LIT>" ) <EOL> self . br [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> self . br [ '<STR_LIT:description>' ] = "<STR_LIT>" <EOL> resp = self . br . submit ( ) <EOL> body = resp . read ( ) <EOL> assert '<STR_LIT>' in resp . geturl ( ) <EOL> assert '<STR_LIT>' in body <EOL> assert '<STR_LIT>' in body <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
