<s> import unittest <EOL> import httpretty <EOL> from wq . io import CsvNetIO <EOL> from wq . io . exceptions import LoadFailed <EOL> import pickle <EOL> from . base import IoTestCase <EOL> class TestIO ( CsvNetIO ) : <EOL> url = "<STR_LIT>" <EOL> class NetLoaderTestCase ( IoTestCase ) : <EOL> def setUp ( self ) : <EOL> httpretty . enable ( ) <EOL> httpretty . register_uri ( <EOL> httpretty . GET , <EOL> "<STR_LIT>" , <EOL> body = "<STR_LIT>" , <EOL> content_type = "<STR_LIT>" <EOL> ) <EOL> httpretty . register_uri ( <EOL> httpretty . GET , <EOL> "<STR_LIT>" , <EOL> body = "<STR_LIT>" , <EOL> content_type = "<STR_LIT>" , <EOL> status = <NUM_LIT> , <EOL> ) <EOL> httpretty . register_uri ( <EOL> httpretty . GET , <EOL> "<STR_LIT>" , <EOL> body = "<STR_LIT>" , <EOL> content_type = "<STR_LIT>" , <EOL> status = <NUM_LIT> , <EOL> ) <EOL> def tearDown ( self ) : <EOL> httpretty . disable ( ) <EOL> httpretty . reset ( ) <EOL> def test_load_csv ( self ) : <EOL> self . check_instance ( TestIO ( ) ) <EOL> def test_load_csv_params ( self ) : <EOL> self . check_instance ( TestIO ( params = { '<STR_LIT:test>' : <NUM_LIT:1> } ) ) <EOL> qs = httpretty . last_request ( ) . querystring <EOL> self . assertEqual ( qs , { '<STR_LIT:test>' : [ '<STR_LIT:1>' ] } ) <EOL> self . check_instance ( TestIO ( params = "<STR_LIT>" ) ) <EOL> qs = httpretty . last_request ( ) . querystring <EOL> self . assertEqual ( qs , { '<STR_LIT:test>' : [ '<STR_LIT:1>' ] } ) <EOL> self . check_instance ( TestIO ( params = None ) ) <EOL> qs = httpretty . last_request ( ) . querystring <EOL> self . assertEqual ( qs , { } ) <EOL> def test_debug_string ( self ) : <EOL> instance = TestIO ( debug = True ) <EOL> self . assertEqual ( <EOL> instance . debug_string , "<STR_LIT>" <EOL> ) <EOL> instance = TestIO ( params = { '<STR_LIT:test>' : <NUM_LIT:1> } , debug = True ) <EOL> self . assertEqual ( <EOL> instance . debug_string , "<STR_LIT>" <EOL> ) <EOL> def test_load_csv_auth ( self ) : <EOL> class AuthTestIO ( CsvNetIO ) : <EOL> url = "<STR_LIT>" <EOL> username = "<STR_LIT:user>" <EOL> password = "<STR_LIT>" <EOL> self . check_instance ( AuthTestIO ( ) ) <EOL> headers = httpretty . last_request ( ) . headers <EOL> auth = "<STR_LIT>" <EOL> self . assertEqual ( headers . get ( '<STR_LIT>' , None ) , auth ) <EOL> def test_load_csv_pickle ( self ) : <EOL> instance = TestIO ( ) <EOL> self . check_instance ( instance ) <EOL> instance = pickle . loads ( pickle . dumps ( instance ) ) <EOL> self . check_instance ( instance ) <EOL> def test_load_fail ( self ) : <EOL> class TestIO ( CsvNetIO ) : <EOL> url = "<STR_LIT>" <EOL> with self . assertRaises ( LoadFailed ) as cm : <EOL> instance = TestIO ( ) <EOL> self . assertEqual ( str ( cm . exception ) , "<STR_LIT>" ) <EOL> def test_load_fail_html ( self ) : <EOL> class TestIO ( CsvNetIO ) : <EOL> url = "<STR_LIT>" <EOL> with self . assertRaises ( LoadFailed ) as cm : <EOL> instance = TestIO ( ) <EOL> self . assertEqual ( str ( cm . exception ) , "<STR_LIT>" ) </s>
