<s> import sys <EOL> import os <EOL> import unittest <EOL> import re <EOL> import web <EOL> from paste . fixture import TestApp <EOL> import logging <EOL> import karesansui <EOL> import karesansui . urls <EOL> username = "<STR_LIT>" <EOL> password = "<STR_LIT:password>" <EOL> class TestRestAPI ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> middleware = [ ] <EOL> self . logger = logging . getLogger ( '<STR_LIT>' ) <EOL> urls = karesansui . urls . urls <EOL> app = web . application ( urls , globals ( ) , autoreload = False ) <EOL> from karesansui . app import load_sqlalchemy_karesansui , load_sqlalchemy_pysilhouette <EOL> app . add_processor ( load_sqlalchemy_karesansui ) <EOL> app . add_processor ( load_sqlalchemy_pysilhouette ) <EOL> self . prefix = "<STR_LIT>" <EOL> if karesansui . config [ '<STR_LIT>' ] : <EOL> mapping = ( karesansui . config [ '<STR_LIT>' ] , app ) <EOL> app = web . subdir_application ( mapping ) <EOL> self . prefix = karesansui . config [ '<STR_LIT>' ] <EOL> self . app = TestApp ( app . wsgifunc ( * middleware ) ) <EOL> self . headers = { } <EOL> if username != None and password != None : <EOL> from base64 import b64encode <EOL> base64string = b64encode ( "<STR_LIT>" % ( username , password ) ) <EOL> self . headers = { "<STR_LIT>" : "<STR_LIT>" % base64string } <EOL> return True <EOL> def tearDown ( self ) : <EOL> return True <EOL> def test_dummy ( self ) : <EOL> self . assertEqual ( True , True ) <EOL> def test_get_index ( self ) : <EOL> r = self . app . get ( "<STR_LIT>" % self . prefix , headers = self . headers ) <EOL> assert_equal ( r . status , <NUM_LIT:200> ) <EOL> r . mustcontain ( '<STR_LIT>' ) <EOL> def test_get_host_1_index ( self ) : <EOL> r = self . app . get ( "<STR_LIT>" % self . prefix , headers = self . headers ) <EOL> assert_equal ( r . status , <NUM_LIT:200> ) <EOL> r . mustcontain ( '<STR_LIT>' ) <EOL> def test_get_host_1_json ( self ) : <EOL> r = self . app . get ( "<STR_LIT>" % self . prefix , headers = self . headers ) <EOL> assert_equal ( r . status , <NUM_LIT:200> ) <EOL> r . mustcontain ( '<STR_LIT>' ) <EOL> def test_get_host_1_guest_2_index ( self ) : <EOL> r = self . app . get ( "<STR_LIT>" % self . prefix , headers = self . headers ) <EOL> assert_equal ( r . status , <NUM_LIT:200> ) <EOL> r . mustcontain ( '<STR_LIT>' ) <EOL> def test_get_host_1_guest_2_json ( self ) : <EOL> r = self . app . get ( "<STR_LIT>" % self . prefix , headers = self . headers ) <EOL> assert_equal ( r . status , <NUM_LIT:200> ) <EOL> r . mustcontain ( '<STR_LIT>' ) <EOL> def test_post_host_1_guest ( self ) : <EOL> params = { } <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:title>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:value>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:default>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> params [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> upload_files = None <EOL> r = self . app . post ( "<STR_LIT>" % self . prefix , params = params , headers = self . headers , upload_files = upload_files ) <EOL> assert_equal ( r . status , <NUM_LIT:200> ) <EOL> r . mustcontain ( '<STR_LIT>' ) <EOL> def test_del_host_1_guest_2 ( self ) : <EOL> r = self . app . delete ( "<STR_LIT>" % self . prefix , headers = self . headers ) <EOL> assert_equal ( r . status , <NUM_LIT:200> ) <EOL> r . mustcontain ( '<STR_LIT>' ) <EOL> class SuiteRestAPI ( unittest . TestSuite ) : <EOL> def __init__ ( self ) : <EOL> tests = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> unittest . TestSuite . __init__ ( self , map ( TestRestAPI , tests ) ) <EOL> def all_suite_restapi ( ) : <EOL> return unittest . TestSuite ( [ SuiteRestAPI ( ) ] ) <EOL> def main ( ) : <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( all_suite_restapi ( ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
