def setUp(self): """ """ self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) set_registry_record( 'enabled_types', ['Document'], interface=IRerSolrpushSettings ) self.published_doc = api.content.create( container=self.portal, type='Document', title='Published Document' ) api.content.transition(obj=self.published_doc, transition='publish') self.unpublished_doc = api.content.create( container=self.portal, type='Document', title='Unpublished Document', ) self.published_news = api.content.create( container=self.portal, type='News Item', title='Published News' ) self.unpublished_news = api.content.create( container=self.portal, type='News Item', title='Unpublished News' ) api.content.transition(obj=self.published_news, transition='publish') init_solr_push()
def setUp(self): """ We create objects before initializing solr settings, so solr core is always empty on setUp. """ self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) set_registry_record( 'enabled_types', ['Document', 'News Item'], interface=IRerSolrpushSettings, ) get_registry_record('enabled_types', interface=IRerSolrpushSettings) init_solr_push() commit() self.document = api.content.create(container=self.portal, type='Document', title='Document foo') api.content.transition(obj=self.document, transition='publish') commit() self.news = api.content.create(container=self.portal, type='News Item', title='News bar') api.content.transition(obj=self.news, transition='publish') commit()
def setUp(self): """ """ self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) set_registry_record( 'enabled_types', ['Document', 'News Item'], interface=IRerSolrpushSettings, ) # initialize solr push, so solr will be populated automatically # on commits init_solr_push() commit() self.doc1 = api.content.create( container=self.portal, type='Document', title='First Document', description='lorem ipsum', subject=['foo', 'bar'], ) self.doc2 = api.content.create( container=self.portal, type='Document', title='Second Document', description='lorem ipsum dolor sit amet', ) self.unpublished_doc = api.content.create( container=self.portal, type='Document', title='Unpublished Document', ) self.published_news = api.content.create( container=self.portal, type='News Item', title='Published News', subject=['foo', 'news category'], ) self.unpublished_news = api.content.create( container=self.portal, type='News Item', title='Unpublished News', subject=['foo'], ) self.event = api.content.create( container=self.portal, type='Event', title='Event', subject=['foo'] ) api.content.transition(obj=self.doc1, transition='publish') commit() api.content.transition(obj=self.doc2, transition='publish') commit() api.content.transition(obj=self.published_news, transition='publish') commit() api.content.transition(obj=self.event, transition='publish') commit()
def setUp(self): """Custom shared utility setup for tests.""" self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) set_registry_record( 'enabled_types', ['Document', 'File'], interface=IRerSolrpushSettings, ) init_solr_push()
def handleReload(self, action): data, errors = self.extractData() init_error = init_solr_push() if init_error: api.portal.show_message( init_error, type="error", request=self.request ) else: api.portal.show_message( _(u"Reloaded schema.xml from SOLR"), request=self.request ) self.request.response.redirect(self.request.getURL())
def test_item_not_indexed_if_solrpush_is_not_ready(self): solr_url = get_registry_record('solr_url', IRerSolrpushSettings) api.content.create(container=self.portal, type='Document', title='foo') commit() res = requests.get('{}/select?q=*%3A*&wt=json'.format(solr_url)).json() self.assertEquals(res['response']['numFound'], 0) init_solr_push() api.content.create(container=self.portal, type='Document', title='bar') commit() res = requests.get('{}/select?q=*%3A*&wt=json'.format(solr_url)).json() # because initial state id private self.assertEquals(res['response']['numFound'], 0) # File types has no wf, so they are published api.content.create(container=self.portal, type='File', title='bar file') commit() res = requests.get('{}/select?q=*%3A*&wt=json'.format(solr_url)).json() self.assertEquals(res['response']['numFound'], 1)
def handleSave(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return self.applyChanges(data) api.portal.show_message(_(u"Changes saved."), request=self.request) init_error = init_solr_push() if init_error: api.portal.show_message( init_error, type="error", request=self.request ) else: api.portal.show_message( _(u"Loaded schema.xml from SOLR"), request=self.request ) self.request.response.redirect(self.request.getURL())