#NEWLINE# def test_plugin_context( self ) : #NEWLINE# #INDENT# container_model = add_plugin ( self . placeholder , BootstrapContainerPlugin , 'en' , glossary = { #NEWLINE# #INDENT# 'breakpoints' : BS3_BREAKPOINT_KEYS , #NEWLINE# #UNINDENT# } ) #NEWLINE# container_plugin = container_model . get_plugin_class_instance ( self . admin_site ) #NEWLINE# self . assertIsInstance ( container_plugin , BootstrapContainerPlugin ) #NEWLINE# row_model = add_plugin ( self . placeholder , BootstrapRowPlugin , 'en' , target = container_model , glossary = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# row_plugin = row_model . get_plugin_class_instance ( ) #NEWLINE# self . assertIsInstance ( row_plugin , BootstrapRowPlugin ) #NEWLINE# column_model = add_plugin ( self . placeholder , BootstrapColumnPlugin , 'en' , target = row_model , glossary = { #NEWLINE# #INDENT# 'xs-column-width' : 'col-xs-12' , #NEWLINE# 'sm-column-width' : 'col-sm-6' , #NEWLINE# 'md-column-width' : 'col-md-4' , #NEWLINE# 'lg-column-width' : 'col-lg-3' , #NEWLINE# #UNINDENT# } ) #NEWLINE# column_plugin = column_model . get_plugin_class_instance ( ) #NEWLINE# self . assertIsInstance ( column_plugin , BootstrapColumnPlugin ) #NEWLINE# image_model = add_plugin ( self . placeholder , BootstrapImagePlugin , 'en' , target = column_model ) #NEWLINE# self . assertIsInstance ( image_model , SharableCascadeElement ) #NEWLINE# image_plugin = image_model . get_plugin_class_instance ( self . admin_site ) #NEWLINE# self . assertIsInstance ( image_plugin , BootstrapImagePlugin ) #NEWLINE# image_plugin . cms_plugin_instance = row_plugin . cmsplugin_ptr #NEWLINE# ModelForm = image_plugin . get_form ( self . request , image_model ) #NEWLINE# image = self . upload_demo_image ( ) #NEWLINE# post_data = QueryDict ( '' , mutable = True ) #NEWLINE# post_data . update ( { #NEWLINE# #INDENT# 'image_file' : image . pk , #NEWLINE# 'link_type' : 'none' , #NEWLINE# 'image-width-fixed' : '300px' , #NEWLINE# #UNINDENT# } ) #NEWLINE# image_model . _image_model = image #NEWLINE# form = ModelForm ( post_data , None , instance = image_model ) #NEWLINE# self . assertTrue ( form . is_valid ( ) ) #NEWLINE# image_plugin . save_model ( self . request , image_model , form , False ) #NEWLINE# plugin_list = [ container_model , row_model , column_model , image_model ] #NEWLINE# build_plugin_tree ( plugin_list ) #NEWLINE# context = get_request_context ( self . request ) #NEWLINE# html = container_model . render_plugin ( context ) #NEWLINE# soup = BeautifulSoup ( html ) #NEWLINE# self . assertEqual ( soup . img [ 'height' ] , '100' ) #NEWLINE# self . assertEqual ( soup . img [ 'width' ] , '300' ) #NEWLINE# self . assertTrue ( ( 'demo_image.png__300x100_q85_subsampling-2' in str ( soup . img ) ) ) #NEWLINE# post_data . setlist ( 'image-shapes' , [ 'img-responsive' ] ) #NEWLINE# form = ModelForm ( post_data , None , instance = image_model ) #NEWLINE# self . assertTrue ( form . is_valid ( ) ) #NEWLINE# image_plugin . save_model ( self . request , image_model , form , False ) #NEWLINE# html = container_model . render_plugin ( context ) #NEWLINE# soup = BeautifulSoup ( html ) #NEWLINE# self . assertTrue ( ( 'img-responsive' in soup . img [ 'class' ] ) ) #NEWLINE# sizes = [ s . strip ( ) for s in soup . img [ 'sizes' ] . split ( ',' ) ] #NEWLINE# self . assertTrue ( ( '(max-width: 768px) 720px' in sizes ) ) #NEWLINE# self . assertTrue ( ( '(min-width: 768px) and (max-width: 992px) 345px' in sizes ) ) #NEWLINE# self . assertTrue ( ( '(min-width: 992px) and (max-width: 1200px) 293px' in sizes ) ) #NEWLINE# self . assertTrue ( ( '(min-width: 1200px) 262px' in sizes ) ) #NEWLINE# srcsets = [ s . strip ( ) for s in soup . img [ 'srcset' ] . split ( ',' ) ] #NEWLINE# self . assertEqual ( len ( [ s for s in srcsets if s . endswith ( 'demo_image.png__293x98_q85_subsampling-2.jpg 293w' ) ] ) , 1 ) #NEWLINE# self . assertEqual ( len ( [ s for s in srcsets if s . endswith ( 'demo_image.png__720x240_q85_subsampling-2.jpg 720w' ) ] ) , 1 ) #NEWLINE# self . assertEqual ( len ( [ s for s in srcsets if s . endswith ( 'demo_image.png__345x115_q85_subsampling-2.jpg 345w' ) ] ) , 1 ) #NEWLINE# self . assertEqual ( len ( [ s for s in srcsets if s . endswith ( 'demo_image.png__262x87_q85_subsampling-2.jpg 262w' ) ] ) , 1 ) #NEWLINE# self . assertTrue ( soup . img [ 'src' ] . endswith ( 'demo_image.png__720x240_q85_subsampling-2.jpg' ) )