<s> from __future__ import unicode_literals <EOL> from bs4 import BeautifulSoup <EOL> from django . conf import settings <EOL> from django . contrib import admin <EOL> from django . test import override_settings <EOL> from cms . api import add_plugin , create_page <EOL> from cms . utils . plugins import build_plugin_tree <EOL> from cmsplugin_cascade . bootstrap3 . container import ( BootstrapContainerPlugin , BootstrapRowPlugin , <EOL> BootstrapColumnPlugin ) <EOL> from cmsplugin_cascade . bootstrap3 . accordion import ( BootstrapAccordionPlugin , <EOL> BootstrapAccordionPanelPlugin ) <EOL> from cmsplugin_cascade . bootstrap3 import settings <EOL> from cms . test_utils . testcases import CMSTestCase <EOL> from . utils import get_request_context <EOL> BS3_BREAKPOINT_KEYS = list ( tp [ <NUM_LIT:0> ] for tp in settings . CMSPLUGIN_CASCADE [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> class AccordionPluginTest ( CMSTestCase ) : <EOL> def setUp ( self ) : <EOL> page = create_page ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , published = True , in_navigation = True ) <EOL> self . placeholder = page . placeholders . get ( slot = '<STR_LIT>' ) <EOL> self . request = self . get_request ( language = '<STR_LIT>' , page = page ) <EOL> self . admin_site = admin . sites . AdminSite ( ) <EOL> def build_accordion_plugins ( self ) : <EOL> container_model = add_plugin ( self . placeholder , BootstrapContainerPlugin , '<STR_LIT>' , <EOL> glossary = { '<STR_LIT>' : BS3_BREAKPOINT_KEYS } ) <EOL> container_plugin = container_model . get_plugin_class_instance ( self . admin_site ) <EOL> self . assertIsInstance ( container_plugin , BootstrapContainerPlugin ) <EOL> row_model = add_plugin ( self . placeholder , BootstrapRowPlugin , '<STR_LIT>' , target = container_model , <EOL> glossary = { } ) <EOL> row_plugin = row_model . get_plugin_class_instance ( ) <EOL> self . assertIsInstance ( row_plugin , BootstrapRowPlugin ) <EOL> column_model = add_plugin ( self . placeholder , BootstrapColumnPlugin , '<STR_LIT>' , target = row_model , <EOL> glossary = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> column_plugin = column_model . get_plugin_class_instance ( ) <EOL> self . assertIsInstance ( column_plugin , BootstrapColumnPlugin ) <EOL> accordion_model = add_plugin ( self . placeholder , BootstrapAccordionPlugin , '<STR_LIT>' , target = column_model ) <EOL> accordion_plugin = accordion_model . get_plugin_class_instance ( self . admin_site ) <EOL> self . assertIsInstance ( accordion_plugin , BootstrapAccordionPlugin ) <EOL> accordion_plugin . cms_plugin_instance = accordion_model . cmsplugin_ptr <EOL> panel_model = add_plugin ( self . placeholder , BootstrapAccordionPanelPlugin , '<STR_LIT>' , <EOL> target = accordion_model , glossary = { '<STR_LIT>' : "<STR_LIT>" , '<STR_LIT>' : "<STR_LIT>" } ) <EOL> panel_plugin = panel_model . get_plugin_class_instance ( self . admin_site ) <EOL> self . assertIsInstance ( panel_plugin , BootstrapAccordionPanelPlugin ) <EOL> panel_plugin . cms_plugin_instance = panel_model . cmsplugin_ptr <EOL> plugin_list = [ container_model , row_model , column_model , accordion_model , panel_model ] <EOL> build_plugin_tree ( plugin_list ) <EOL> context = get_request_context ( self . request ) <EOL> self . assertEqual ( accordion_plugin . get_identifier ( accordion_model ) , '<STR_LIT>' ) <EOL> self . assertEqual ( panel_plugin . get_identifier ( panel_model ) , '<STR_LIT>' ) <EOL> return container_model . render_plugin ( context ) <EOL> @ override_settings ( ) <EOL> def test_bootstrap_accordion ( self ) : <EOL> try : <EOL> del settings . CMSPLUGIN_CASCADE [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> pass <EOL> html = self . build_accordion_plugins ( ) <EOL> soup = BeautifulSoup ( html ) <EOL> panel_group = soup . find ( '<STR_LIT>' , class_ = '<STR_LIT>' ) <EOL> self . assertIsNotNone ( panel_group ) <EOL> @ override_settings ( ) <EOL> def test_angular_bootstrap_accordion ( self ) : <EOL> settings . CMSPLUGIN_CASCADE [ '<STR_LIT>' ] . update ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> html = self . build_accordion_plugins ( ) <EOL> soup = BeautifulSoup ( html ) <EOL> accordion = soup . find ( '<STR_LIT>' ) <EOL> self . assertIsNotNone ( accordion ) </s>
