Ejemplo n.º 1
0
    def test_new_table(self):
        drop_if_exists(self.unloaded_meta.dataset_name)

        etl = PlenarioETL(self.unloaded_meta, source_path=self.radio_path)
        new_table = etl.add()

        all_rows = session.execute(new_table.select()).fetchall()
        self.assertEqual(len(all_rows), 5)
        session.close()
        new_table.drop(app_engine, checkfirst=True)

        # Did we add a bbox?
        bbox = MetaTable.get_by_dataset_name('community_radio_events').bbox
        self.assertIsNotNone(bbox)
Ejemplo n.º 2
0
    def test_location_col_add(self):
        drop_if_exists(self.opera_meta.dataset_name)

        etl = PlenarioETL(self.opera_meta, source_path=self.opera_path)
        new_table = etl.add()

        all_rows = session.execute(new_table.select()).fetchall()
        self.assertEqual(len(all_rows), 5)
        session.close()
        new_table.drop(app_engine, checkfirst=True)

        # Did we add a bbox?
        bbox = MetaTable.get_by_dataset_name('public_opera_performances').bbox
        self.assertIsNotNone(bbox)
Ejemplo n.º 3
0
    def test_location_col_add(self):
        drop_if_exists(self.opera_meta.dataset_name)

        etl = PlenarioETL(self.opera_meta, source_path=self.opera_path)
        new_table = etl.add()

        all_rows = session.execute(new_table.select()).fetchall()
        self.assertEqual(len(all_rows), 5)
        session.close()
        new_table.drop(app_engine, checkfirst=True)

        # Did we add a bbox?
        bbox = MetaTable.get_by_dataset_name('public_opera_performances').bbox
        self.assertIsNotNone(bbox)
Ejemplo n.º 4
0
    def test_new_table(self):
        drop_if_exists(self.unloaded_meta.dataset_name)

        etl = PlenarioETL(self.unloaded_meta, source_path=self.radio_path)
        new_table = etl.add()

        all_rows = session.execute(new_table.select()).fetchall()
        self.assertEqual(len(all_rows), 5)
        session.close()
        new_table.drop(app_engine, checkfirst=True)

        # Did we add a bbox?
        bbox = MetaTable.get_by_dataset_name('community_radio_events').bbox
        self.assertIsNotNone(bbox)
Ejemplo n.º 5
0
    def test_new_table_has_correct_column_names_in_meta(self):
        drop_if_exists(self.unloaded_meta.dataset_name)

        etl = PlenarioETL(self.unloaded_meta, source_path=self.radio_path)
        new_table = etl.add()

        columns = session.query(MetaTable.column_names)
        columns = columns.filter(MetaTable.dataset_name == self.unloaded_meta.dataset_name)
        columns = columns.first()[0]

        self.assertEqual(len(columns), 4)

        session.close()
        new_table.drop(app_engine, checkfirst=True)
Ejemplo n.º 6
0
def add_dataset(self, source_url_hash, data_types=None):
    md = session.query(MetaTable).get(source_url_hash)
    session.close()
    if md.result_ids:
        ids = md.result_ids
        ids.append(self.request.id)
    else:
        ids = [self.request.id]
    with engine.begin() as c:
        c.execute(MetaTable.__table__.update()\
            .where(MetaTable.source_url_hash == source_url_hash)\
            .values(result_ids=ids))

    etl = PlenarioETL(md)
    etl.add()
    return 'Finished adding {0} ({1})'.format(md.human_name, md.source_url_hash)
Ejemplo n.º 7
0
 def tearDown(self):
     session.close()
Ejemplo n.º 8
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     """
     Drop the staging table if it's been created.
     """
     session.close()
     self._drop()
Ejemplo n.º 9
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     """
     Drop the staging table if it's been created.
     """
     session.close()
     self._drop()
Ejemplo n.º 10
0
 def tearDown(self):
     session.close()