def test_table_task():
    '''
    Very simple table task should run and make an entry in OBSTable, as
    well as a physical table with rows in observatory schema.
    '''
    task = TestTableTask()
    runtask(task)
    table = task.output().get(current_session())
    assert_is_not_none(table)
    assert_is_none(table.the_geom)
    assert_equal(current_session().execute(
        'SELECT COUNT(*) FROM observatory.{}'.format(
            table.tablename)).fetchone()[0], 1)
Exemple #2
0
def test_table_task():
    '''
    Very simple table task should run and make an entry in OBSTable, as
    well as a physical table with rows in observatory schema.
    '''
    task = TestTableTask()
    runtask(task)
    table = task.output().get(current_session())
    assert_is_not_none(table)
    assert_is_none(table.the_geom)
    assert_equal(
        current_session().execute('SELECT COUNT(*) FROM observatory.{}'.format(
            table.tablename)).fetchone()[0], 1)
def test_geom_table_task_update():
    '''
    Should be possible to generate a new version of a table by incrementing
    the version number.
    '''
    task = TestGeomTableTask()
    runtask(task)
    assert_true(task.complete())
    task = TestGeomTableTask()
    task.version = lambda: 10
    assert_false(task.complete())
    current_session().commit()
    runtask(task)
    assert_true(task.complete())
Exemple #4
0
def test_geom_table_task_update():
    '''
    Should be possible to generate a new version of a table by incrementing
    the version number.
    '''
    task = TestGeomTableTask()
    runtask(task)
    assert_true(task.complete())
    task = TestGeomTableTask()
    task.version = lambda: 10
    assert_false(task.complete())
    current_session().commit()
    runtask(task)
    assert_true(task.complete())
def test_carto_2_temp_table_task():
    '''
    Convert a table on CARTO to a temp table.
    '''
    task = TestCSV2TempTableTask()
    before_table_count = current_session().execute(
        'SELECT COUNT(*) FROM observatory.obs_table').fetchone()[0]
    runtask(task)
    table = task.output()
    assert_equal(current_session().execute(
        'SELECT COUNT(*) FROM {}'.format(
            table.table)).fetchone()[0], 10)
    after_table_count = current_session().execute(
        'SELECT COUNT(*) FROM observatory.obs_table').fetchone()[0]
    assert_equal(before_table_count, after_table_count)
Exemple #6
0
def test_carto_2_temp_table_task():
    '''
    Convert a table on CARTO to a temp table.
    '''
    task = TestCSV2TempTableTask()
    before_table_count = current_session().execute(
        'SELECT COUNT(*) FROM observatory.obs_table').fetchone()[0]
    runtask(task)
    table = task.output()
    assert_equal(
        current_session().execute('SELECT COUNT(*) FROM {}'.format(
            table.table)).fetchone()[0], 10)
    after_table_count = current_session().execute(
        'SELECT COUNT(*) FROM observatory.obs_table').fetchone()[0]
    assert_equal(before_table_count, after_table_count)
 def populate(self):
     session = current_session()
     session.execute(
         "INSERT INTO {output} VALUES "
         "(ST_SetSRID(ST_MakeEnvelope(-10, 10, 10, -10), 4326), 'foo', 100)".format(
             output=self.output().table
         ))
def test_csv_2_temp_table_task():
    '''
    CSV to temp table task should run and generate no entry in OBSTable, but
    a physical table in the right schema.
    '''
    task = TestCSV2TempTableTask()
    before_table_count = current_session().execute(
        'SELECT COUNT(*) FROM observatory.obs_table').fetchone()[0]
    runtask(task)
    table = task.output()
    assert_equal(current_session().execute(
        'SELECT COUNT(*) FROM {}'.format(
            table.table)).fetchone()[0], 10)
    after_table_count = current_session().execute(
        'SELECT COUNT(*) FROM observatory.obs_table').fetchone()[0]
    assert_equal(before_table_count, after_table_count)
def test_geom_table_task():
    '''
    Table task with geoms should run and generate an entry in OBSTable with
    a summary geom, plus a physical table with rows in observatory schema.

    It should also generate a raster tile summary.
    '''
    task = TestGeomTableTask()
    runtask(task)
    table = task.output().get(current_session())
    assert_is_not_none(table)
    assert_is_not_none(table.the_geom)
    assert_equal(current_session().execute(
        'SELECT COUNT(*) FROM observatory.{}'.format(
            table.tablename)).fetchone()[0], 1)
    assert_greater(current_session().query(OBSColumnTableTile).count(), 0)
Exemple #10
0
def test_csv_2_temp_table_task():
    '''
    CSV to temp table task should run and generate no entry in OBSTable, but
    a physical table in the right schema.
    '''
    task = TestCSV2TempTableTask()
    before_table_count = current_session().execute(
        'SELECT COUNT(*) FROM observatory.obs_table').fetchone()[0]
    runtask(task)
    table = task.output()
    assert_equal(
        current_session().execute('SELECT COUNT(*) FROM {}'.format(
            table.table)).fetchone()[0], 10)
    after_table_count = current_session().execute(
        'SELECT COUNT(*) FROM observatory.obs_table').fetchone()[0]
    assert_equal(before_table_count, after_table_count)
Exemple #11
0
def test_geom_table_task():
    '''
    Table task with geoms should run and generate an entry in OBSTable with
    a summary geom, plus a physical table with rows in observatory schema.

    It should also generate a raster tile summary.
    '''
    task = TestGeomTableTask()
    runtask(task)
    table = task.output().get(current_session())
    assert_is_not_none(table)
    assert_is_not_none(table.the_geom)
    assert_equal(
        current_session().execute('SELECT COUNT(*) FROM observatory.{}'.format(
            table.tablename)).fetchone()[0], 1)
    assert_greater(current_session().query(OBSColumnTableTile).count(), 0)
 def populate(self):
     session = current_session()
     session.execute("INSERT INTO {output} VALUES ('foo', 100)".format(
         output=self.output().table
     ))
Exemple #13
0
 def populate(self):
     session = current_session()
     session.execute(
         "INSERT INTO {output} VALUES "
         "(ST_SetSRID(ST_MakeEnvelope(-10, 10, 10, -10), 4326), 'foo', 100)"
         .format(output=self.output().table))
Exemple #14
0
 def populate(self):
     session = current_session()
     session.execute("INSERT INTO {output} VALUES ('foo', 100)".format(
         output=self.output().table))