def test_customize_placeholder_by_setting_property(self): self.portal._setProperty('search_label', 'Search example.com', 'string') transaction.commit() Plone().visit_portal() self.assertEquals('Search example.com', SearchBox().search_field_placeholder)
def test_default_plone_placeholder_is_used_by_deafult(self): Plone().visit_portal() default_placeholder = translate('title_search_site', domain='plone', context=self.request) self.assertEquals(default_placeholder, SearchBox().search_field_placeholder)
def test_default_plone_placeholder_is_used_by_deafult(self, browser): browser.open() default_placeholder = translate('title_search_site', default='Search this site', domain='plone', context=self.request) self.assertEquals(default_placeholder, SearchBox().search_field_placeholder)
def test_placeholder_property_can_be_overriden_on_any_context(self): self.portal._setProperty('search_label', 'search portal', 'string') folder = create(Builder('folder')) folder._setProperty('search_label', 'search folder', 'string') transaction.commit() placeholders = {} Plone().login().visit_portal() placeholders['portal'] = SearchBox().search_field_placeholder Plone().visit(folder) placeholders['folder'] = SearchBox().search_field_placeholder self.assertEquals( { 'portal': 'search portal', 'folder': 'search folder' }, placeholders)
def test_placeholder_property_is_inherited(self): self.portal._setProperty('search_label', 'search site', 'string') folder = create(Builder('folder')) Plone().login().visit(folder) self.assertEquals('search site', SearchBox().search_field_placeholder)
def test_has_solr_cssclass_present_when_solr_enabled(self): Plone().login().visit_portal() self.assertTrue(SearchBox().has_solr, 'The has-solr class is missing on the search <form>') self.assertFalse(SearchBox().no_solr, 'There is a has-solr AND a no-solr class!?')
def test_form_action_is_view_when_solr_enabled(self): Plone().login().visit_portal() self.assertEquals('http://nohost/plone/@@search', SearchBox().form_action)
def test_form_action_is_page_template_when_solr_disabled(self): Plone().login().visit_portal() self.assertEquals('http://nohost/plone/search', SearchBox().form_action)
def test_empty_placeholder_by_setting_property(self, browser): self.portal._setProperty('search_label', '', 'string') transaction.commit() browser.open() self.assertEquals('', SearchBox().search_field_placeholder)
def test_has_solr_cssclass_present_when_solr_enabled(self, browser): browser.login().open() self.assertTrue(SearchBox().has_solr, 'The has-solr class is missing on the search <form>') self.assertFalse(SearchBox().no_solr, 'There is a has-solr AND a no-solr class!?')
def test_form_action_is_view_when_solr_enabled(self, browser): browser.login().open() self.assertEquals('http://nohost/plone/@@search', SearchBox().form_action)
def test_form_action_is_page_template_when_solr_disabled(self, browser): browser.login().open() self.assertEquals('http://nohost/plone/search', SearchBox().form_action)