def test_selectbutton_id(self): mockvalue = mock.MagicMock() mockvalue.pk = 10 selector = htmls.S( listbuilder_itemvalues.ItemValue(value=mockvalue).render()) self.assertTrue( selector.exists( 'button#cradmin_legacy_multiselect2_selectbutton_10'))
def test_selectbutton_text(self): mockvalue = mock.MagicMock() selector = htmls.S( listbuilder_itemvalues.ItemValue(value=mockvalue).render()) self.assertEqual( 'Select', selector.one('button.cradmin-legacy-multiselect2-itemvalue-button' ).alltext_normalized)
def test_no_description(self): mockvalue = mock.MagicMock() selector = htmls.S( listbuilder_itemvalues.ItemValue(value=mockvalue).render()) self.assertFalse( selector.exists( '.cradmin-legacy-listbuilder-itemvalue-titledescription-description' ))
def test_angularjs_directive_custom_target_dom_id(self): mockvalue = mock.MagicMock() selector = htmls.S( listbuilder_itemvalues.ItemValue(value=mockvalue, target_dom_id='testid').render()) directiveoptions = json.loads( selector.one('button.cradmin-legacy-multiselect2-itemvalue-button') ['cradmin-legacy-multiselect2-select']) self.assertEqual('testid', directiveoptions['target_dom_id'])
def test_angularjs_directive_is_selected_true(self): mockvalue = mock.MagicMock() selector = htmls.S( listbuilder_itemvalues.ItemValue(value=mockvalue, is_selected=True).render()) directiveoptions = json.loads( selector.one('button.cradmin-legacy-multiselect2-itemvalue-button') ['cradmin-legacy-multiselect2-select']) self.assertTrue(directiveoptions['is_selected'])
def test_selectbutton_aria_label(self): mockvalue = mock.MagicMock() mockvalue.__str__.return_value = 'testvalue' if python2_compatibility.is_python2(): mockvalue.__unicode__.return_value = 'testvalue' selector = htmls.S( listbuilder_itemvalues.ItemValue(value=mockvalue).render()) self.assertEqual( 'Select "testvalue"', selector.one('button.cradmin-legacy-multiselect2-itemvalue-button') ['aria-label'])
def test_title(self): mockvalue = mock.MagicMock() mockvalue.__str__.return_value = 'testvalue' if python2_compatibility.is_python2(): mockvalue.__unicode__.return_value = 'testvalue' selector = htmls.S( listbuilder_itemvalues.ItemValue(value=mockvalue).render()) self.assertEqual( 'testvalue', selector.one( '.cradmin-legacy-listbuilder-itemvalue-titledescription-title' ).alltext_normalized)
def test_angularjs_directive(self): mockvalue = mock.MagicMock() selector = htmls.S( listbuilder_itemvalues.ItemValue(value=mockvalue).render()) directiveoptions = json.loads( selector.one('button.cradmin-legacy-multiselect2-itemvalue-button') ['cradmin-legacy-multiselect2-select']) self.assertEqual( { 'custom_data': None, 'is_selected': False, 'item_wrapper_css_selector': 'li', 'preview_container_css_selector': '.cradmin-legacy-multiselect2-itemvalue', 'preview_css_selector': '.cradmin-legacy-multiselect2-selected-item', 'target_dom_id': 'cradmin_legacy_multiselect2_select_target' }, directiveoptions)