def testGetDataRecord(self): mapObj = Map.by_id(10000023, self.dbsession) response = createSearchRecord(mapObj, self.dbsession, self.logger, self.georefProcess) print '=====================' print 'Test if testGetDataRecord ...' print 'Response: %s'%response print '=====================' self.assertTrue('oai:de:slub-dresden:vk:id-10000023' in response, 'Missing key in response') self.assertEqual(response['oai:de:slub-dresden:vk:id-10000023']['dataid'], 'df_dk_0010001_4630_1928', 'Dataid has not expected value')
def pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj=None): """ Push the metadata for a given mapObj to the search index (actual ElasticSearch). :type georeference.models.vkdb.map.Map: mapObj :type sqlalchemy.orm.session.Session: dbsession :type logging.Logger: logger :type georefObj: georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess|None :return: str RecordId of the ElasticSearch record """ datarecord = createSearchRecord(mapObj, dbsession, logger, georefObj) return pushRecordToEs(datarecord, ELASTICSEARCH_INDEX, logger)
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")