def test_relational_ents_mk_tbl(self): ents = [{'vals' : [{'meta_instanceId': 1}], 'col' : 'table1'}, {'vals' : [{'meta_instanceId': 1, 'col2': 2}], 'col' : 'table2'}, {'vals' : [{'meta_instanceId': 3}], 'col' : 'table1'}] db.relational_ents(None, 'bob', ents) self.assertEqual(sorted([t.name for t in db.metadata.tables.values()]), sorted(['bob_table1', 'bob_table2']))
def test_relational_ents_mk_tbl(self): ents = [{'vals': [{'meta_instanceId': 1}], 'col': 'table1'}, {'vals': [{'meta_instanceId': 1, 'col2': 2}], 'col': 'table2'}, {'vals': [{'meta_instanceId': 3}], 'col': 'table1'}] db.relational_ents(None, 'bob', ents) self.assertEqual( sorted([t.name for t in db.metadata.tables.values()]), sorted(['bob_table1', 'bob_table2']))
rel = [] #go through all the entries for a given survey for sl in walk(cd).next()[1]: ent = _get_an_entry(join(cd, sl) + '/', surname) cont += [ent['content']] cont, rel = _break_up(cont) #store main entries logger.info('***Storing main table entries***') db.store(cont, ent['id']) logger.info('***Storing relational info***') #store relational entries' db.relational_ents(schema, surname, rel) #get and store OSM data osm.store_an_osm(cont, ent['id']) def get_all_surveys(schema): """ iterate through all surveys""" base = DEST_LOC + DV surveys = [f for f in listdir(base) if not isfile(join(base, f))] logger.info('****Extracting the following surveys...****') logger.info(surveys) #directory structure: .../submissions/date_file/surveys/entry_id/.osm|.xml|.json #traverse through to get entries and their data files
rel = [] # go through all the entries for a given survey for sl in walk(cd).next()[1]: ent = _get_an_entry(join(cd, sl) + '/', surname) cont += [ent['content']] cont, rel = _break_up(cont) # store main entries logger.info('***Storing main table entries***') db.store(cont, ent['id']) logger.info('***Storing relational info***') # store relational entries' db.relational_ents(schema, surname, rel) # get and store OSM data osm.store_an_osm(cont, ent['id']) def get_all_surveys(schema): """ iterate through all surveys""" base = DEST_LOC + DV surveys = [f for f in listdir(base) if not isfile(join(base, f))] logger.info('****Extracting the following surveys...****') logger.info(surveys) # directory structure: # .../submissions/date_file/surveys/entry_id/.osm|.xml|.json