<s> from . base import LassieBaseTestCase <EOL> from lassie import Lassie , LassieError <EOL> class LassieCoreTestCase ( LassieBaseTestCase ) : <EOL> def test_core_class_vs_method_settings ( self ) : <EOL> url = '<STR_LIT>' <EOL> l = Lassie ( ) <EOL> data = l . fetch ( url ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> l . open_graph = False <EOL> data = l . fetch ( url ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:0> ) <EOL> def test_core_class_setting_is_none ( self ) : <EOL> url = '<STR_LIT>' <EOL> l = Lassie ( ) <EOL> l . open_graph = None <EOL> data = l . fetch ( url , open_graph = False ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:0> ) <EOL> def test_core_no_content_raises_error ( self ) : <EOL> url = '<STR_LIT>' <EOL> l = Lassie ( ) <EOL> self . assertRaises ( LassieError , l . fetch , url ) <EOL> def test_core_retrieve_all_images ( self ) : <EOL> url = '<STR_LIT>' <EOL> l = Lassie ( ) <EOL> l . all_images = True <EOL> data = l . fetch ( url ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:3> ) <EOL> last_image = data [ '<STR_LIT>' ] [ <NUM_LIT:2> ] <EOL> self . assertEqual ( last_image [ '<STR_LIT:width>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( last_image [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_image_dimensions ( self ) : <EOL> url = '<STR_LIT>' <EOL> l = Lassie ( ) <EOL> data = l . fetch ( url , all_images = True ) <EOL> self . assertEqual ( len ( data [ '<STR_LIT>' ] ) , <NUM_LIT:4> ) <EOL> image = data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . assertEqual ( image [ '<STR_LIT:width>' ] , <NUM_LIT:100> ) <EOL> self . assertEqual ( image [ '<STR_LIT>' ] , <NUM_LIT:100> ) <EOL> image = data [ '<STR_LIT>' ] [ <NUM_LIT:1> ] <EOL> self . assertEqual ( image [ '<STR_LIT:width>' ] , <NUM_LIT:100> ) <EOL> self . assertEqual ( image [ '<STR_LIT>' ] , <NUM_LIT:100> ) <EOL> image = data [ '<STR_LIT>' ] [ <NUM_LIT:2> ] <EOL> self . assertEqual ( image [ '<STR_LIT:width>' ] , <NUM_LIT:100> ) <EOL> self . assertEqual ( image [ '<STR_LIT>' ] , <NUM_LIT:100> ) <EOL> image = data [ '<STR_LIT>' ] [ <NUM_LIT:3> ] <EOL> self . assertEqual ( image [ '<STR_LIT:width>' ] , <NUM_LIT:100> ) <EOL> self . assertEqual ( image [ '<STR_LIT>' ] , <NUM_LIT:100> ) <EOL> def test_bad_image_dimensions ( self ) : <EOL> url = '<STR_LIT>' <EOL> l = Lassie ( ) <EOL> data = l . fetch ( url , all_images = True ) <EOL> image = data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . assertTrue ( not '<STR_LIT:width>' in image ) <EOL> self . assertTrue ( not '<STR_LIT>' in image ) <EOL> def test_request_opts ( self ) : <EOL> l = Lassie ( ) <EOL> l . request_opts = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : <NUM_LIT:3> <EOL> } <EOL> self . assertTrue ( set ( ( '<STR_LIT>' , '<STR_LIT>' ) ) . issubset ( l . request_opts ) ) <EOL> l . request_opts [ '<STR_LIT>' ] . update ( { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( len ( l . request_opts [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> self . assertTrue ( set ( ( '<STR_LIT>' , '<STR_LIT:Content-Type>' ) ) . issubset ( l . request_opts [ '<STR_LIT>' ] ) ) <EOL> def test_bad_request_opts ( self ) : <EOL> l = Lassie ( ) <EOL> l . request_opts = { <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> } <EOL> self . assertTrue ( '<STR_LIT>' not in l . request_opts ) <EOL> self . assertTrue ( '<STR_LIT>' in l . request_opts ) <EOL> def test_core_bad_keywords ( self ) : <EOL> url = '<STR_LIT>' <EOL> l = Lassie ( ) <EOL> data = l . fetch ( url ) <EOL> self . assertEqual ( data . get ( '<STR_LIT>' ) , [ ] ) </s>
