#NEWLINE# def test_copy_plugins_method( self ) : #NEWLINE# #INDENT# '\n        Test that CMSPlugin copy does not have side effects\n        ' #NEWLINE# page_en = api . create_page ( 'CopyPluginTestPage (EN)' , 'nav_playground.html' , 'en' ) #NEWLINE# page_de = api . create_page ( 'CopyPluginTestPage (DE)' , 'nav_playground.html' , 'de' ) #NEWLINE# ph_en = page_en . placeholders . get ( slot = 'body' ) #NEWLINE# ph_de = page_de . placeholders . get ( slot = 'body' ) #NEWLINE# text_plugin_en = api . add_plugin ( ph_en , 'TextPlugin' , 'en' , body = 'Hello World' ) #NEWLINE# self . assertEqual ( text_plugin_en . pk , CMSPlugin . objects . all ( ) [ 0 ] . pk ) #NEWLINE# link_plugin_en = api . add_plugin ( ph_en , 'LinkPlugin' , 'en' , target = text_plugin_en , name = 'A Link' , url = 'https://www.django-cms.org' ) #NEWLINE# text_plugin_en . body += plugin_to_tag ( link_plugin_en ) #NEWLINE# text_plugin_en . save ( ) #NEWLINE# text_plugin_en = self . reload ( text_plugin_en ) #NEWLINE# plugins = [ text_plugin_en , link_plugin_en ] #NEWLINE# old_ids = [ plugin . pk for plugin in plugins ] #NEWLINE# new_plugins = [ ] #NEWLINE# plugins_ziplist = [ ] #NEWLINE# old_parent_cache = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for plugin in plugins : #NEWLINE# #INDENT# new_plugins . append ( plugin . copy_plugin ( ph_de , 'de' , old_parent_cache ) ) #NEWLINE# plugins_ziplist . append ( ( new_plugins [ ( - 1 ) ] , plugin ) ) #NEWLINE# #UNINDENT# for ( idx , plugin ) in enumerate ( plugins ) : #NEWLINE# #INDENT# ( inst , _ ) = new_plugins [ idx ] . get_plugin_instance ( ) #NEWLINE# new_plugins [ idx ] = inst #NEWLINE# new_plugins [ idx ] . post_copy ( plugin , plugins_ziplist ) #NEWLINE# #UNINDENT# for ( idx , plugin ) in enumerate ( plugins ) : #NEWLINE# #INDENT# self . assertEqual ( old_ids [ idx ] , plugin . pk ) #NEWLINE# self . assertNotEqual ( new_plugins [ idx ] , plugin . pk ) #NEWLINE# if ( plugin . plugin_type == 'TextPlugin' ) : #NEWLINE# #INDENT# self . assertTrue ( ( 'link.png' in plugin . body ) ) #NEWLINE# self . assertTrue ( ( ( 'plugin_obj_%s' % plugin . get_children ( ) [ 0 ] . pk ) in plugin . body ) ) #NEWLINE# self . assertTrue ( ( 'link.png' in new_plugins [ idx ] . body ) ) #NEWLINE# self . assertTrue ( ( ( 'plugin_obj_%s' % new_plugins [ idx ] . get_children ( ) [ 0 ] . pk ) in new_plugins [ idx ] . body ) )