Exemple #1
0
    def index_callback(self, parsed_message):
        logger.debug("Processing `index` message for entity: %s" %
                     parsed_message.entity_type)
        entity = SCHEMA[parsed_message.entity_type]
        converter = entity.query_result_to_dict
        query = entity.query

        condition = and_(entity.model.id.in_(parsed_message.ids))

        with db_session_ctx(self.session) as session:
            query = query.filter(condition).with_session(session)
            send_data_to_solr(self.cores[parsed_message.entity_type],
                              [converter(obj) for obj in query.all()])
Exemple #2
0
 def test_fail_send(self):
     self.solr_connection.add.side_effect = SolrError('Test Error')
     self.assertFalse(FAILED.value)
     send_data_to_solr(self.solr_connection, [{"foo": "bar"}])
     self.assertTrue(FAILED.value)
Exemple #3
0
 def test_normal_send(self):
     send_data_to_solr(self.solr_connection, [{"foo": "bar"}])
     expected = [mock.call([{"foo": "bar"}])]
     calls = self.solr_connection.add.call_args_list
     self.assertEqual(calls, expected)
Exemple #4
0
 def test_bad_request_ignored(self):
     self.solr_connection.add_many.side_effect = [SolrException(400), None]
     send_data_to_solr(self.solr_connection, 1)
Exemple #5
0
 def test_normal_send(self):
     send_data_to_solr(self.solr_connection, [{"foo": "bar"}])
     expected = [mock.call([{"foo": "bar"}])]
     calls = self.solr_connection.add_many.call_args_list
     self.assertEqual(calls, expected)
Exemple #6
0
 def test_fail_send(self):
     self.solr_connection.add.side_effect = SolrError('Test Error')
     self.assertFalse(FAILED.value)
     send_data_to_solr(self.solr_connection, [{"foo": "bar"}])
     self.assertTrue(FAILED.value)