Example #1
0
def removeRecordFromSearchIndex(mapObj):
    """ Removes the equivalent record from the search index. Instead georeference is set to false

    :deprecated:
    :type georeference.models.vkdb.map.Map: mapObj
    :return:
    """
    key = OAI_ID_PATTERN % mapObj.id
    deleteRecordFromEsById(key, ELASTICSEARCH_INDEX)
Example #2
0
def removeRecordFromSearchIndex(mapObj):
    """ Removes the equivalent record from the search index. Instead georeference is set to false

    :deprecated:
    :type georeference.models.vkdb.map.Map: mapObj
    :return:
    """
    key = OAI_ID_PATTERN%mapObj.id
    deleteRecordFromEsById(key, ELASTICSEARCH_INDEX)
    def testPushRecordToEs(self):
        mapObj = Map.by_id(10000023, self.dbsession)
        datarecord = createSearchRecord(mapObj, self.dbsession, self.logger)
        key = pushRecordToEs(datarecord, ELASTICSEARCH_INDEX, self.logger)

        print '====================='
        print 'Test if testPushRecordToEs ...'
        print 'Response: %s'%key
        print '====================='
        
        # check if the record was insert correctly
        response = getRecordFromEsById(key, ELASTICSEARCH_INDEX)
        self.assertEqual(response['found'], True, 'Could not find expected record')
        self.assertEqual(response['_id'], key, 'Key is not like expected')

        # clear up 
        response = deleteRecordFromEsById(key, ELASTICSEARCH_INDEX)
        if response['found'] is not True:
            raise Exception("Problems while trying to clean up elasticsearch test index")
    def testPushRecordToEs(self):
        mapObj = Map.by_id(10000023, self.dbsession)
        datarecord = createSearchRecord(mapObj, self.dbsession, self.logger)
        key = pushRecordToEs(datarecord, ELASTICSEARCH_INDEX, self.logger)

        print '====================='
        print 'Test if testPushRecordToEs ...'
        print 'Response: %s' % key
        print '====================='

        # check if the record was insert correctly
        response = getRecordFromEsById(key, ELASTICSEARCH_INDEX)
        self.assertEqual(response['found'], True,
                         'Could not find expected record')
        self.assertEqual(response['_id'], key, 'Key is not like expected')

        # clear up
        response = deleteRecordFromEsById(key, ELASTICSEARCH_INDEX)
        if response['found'] is not True:
            raise Exception(
                "Problems while trying to clean up elasticsearch test index")
    def testActivate(self):
        print "--------------------------------------------------------------------------------------------"
        print "\n"
        print "Test if testProcessGeorefImage runs correctly ..."

        key = activate(self.process, self.map, self.dbsession, self.logger)
        self.assertTrue(self.process.processed)
        self.assertTrue(self.map.isttransformiert)
        self.assertTrue(len(self.map.georefimage) > 10)

        # check if the record was added to elasticsearch and remove it when necessary
        response = getRecordFromEsById(key, ELASTICSEARCH_INDEX)
        self.assertEqual(response['found'], True,
                         'Could not find expected record')
        self.assertEqual(response['_id'], key, 'Key is not like expected')

        # clear up
        response = deleteRecordFromEsById(key, ELASTICSEARCH_INDEX)
        if response['found'] is not True:
            raise Exception(
                "Problems while trying to clean up elasticsearch test index")