def test_bad_config_geopackage_no_gpkg_contents(self, app, base_dir): gpkg_file = base_dir.join("cache.gpkg").strpath table_name = "no_gpkg_contents" with sqlite3.connect(gpkg_file) as db: cur = db.execute( """SELECT name FROM sqlite_master WHERE type='table' AND name=?""", (table_name, ), ) content = cur.fetchone() assert content[0] == table_name with sqlite3.connect(gpkg_file) as db: cur = db.execute( """SELECT table_name FROM gpkg_contents WHERE table_name=?""", (table_name, ), ) content = cur.fetchone() assert not content GeopackageCache(gpkg_file, TileGrid(srs=4326), table_name=table_name) with sqlite3.connect(gpkg_file) as db: cur = db.execute( """SELECT table_name FROM gpkg_contents WHERE table_name=?""", (table_name, ), ) content = cur.fetchone() assert content[0] == table_name
def setup(self): TileCacheTestBase.setup(self) self.gpkg_file = os.path.join(self.cache_dir, 'tmp.gpkg') self.table_name = 'test_tiles' self.cache = GeopackageCache( self.gpkg_file, tile_grid=tile_grid(3857, name='global-webmarcator'), table_name=self.table_name, )
def test_bad_config_geopackage_srs(self): error_msg = None gpkg_file = os.path.join( os.path.join(os.path.dirname(__file__), 'fixture'), 'cache.gpkg') table_name = 'cache' try: GeopackageCache(gpkg_file, TileGrid(srs=4326), table_name) except ValueError as ve: error_msg = ve assert "srs is improperly configured." in str(error_msg)
def test_bad_config_geopackage_no_spatial_ref_sys(self): gpkg_file = os.path.join(test_config['base_dir'], 'cache.gpkg') organization_coordsys_id = 3785 table_name='no_gpkg_spatial_ref_sys' with sqlite3.connect(gpkg_file) as db: cur = db.execute('''SELECT organization_coordsys_id FROM gpkg_spatial_ref_sys WHERE organization_coordsys_id=?''', (organization_coordsys_id,)) content = cur.fetchone() assert not content GeopackageCache(gpkg_file, TileGrid(srs=3785), table_name=table_name) with sqlite3.connect(gpkg_file) as db: cur = db.execute( '''SELECT organization_coordsys_id FROM gpkg_spatial_ref_sys WHERE organization_coordsys_id=?''', (organization_coordsys_id,)) content = cur.fetchone() assert content[0] == organization_coordsys_id
def test_bad_config_geopackage_no_spatial_ref_sys(self, base_dir): gpkg_file = base_dir.join("cache.gpkg").strpath organization_coordsys_id = 3785 table_name = "no_gpkg_spatial_ref_sys" with sqlite3.connect(gpkg_file) as db: cur = db.execute( """SELECT organization_coordsys_id FROM gpkg_spatial_ref_sys WHERE organization_coordsys_id=?""", (organization_coordsys_id, ), ) content = cur.fetchone() assert not content GeopackageCache(gpkg_file, TileGrid(srs=3785), table_name=table_name) with sqlite3.connect(gpkg_file) as db: cur = db.execute( """SELECT organization_coordsys_id FROM gpkg_spatial_ref_sys WHERE organization_coordsys_id=?""", (organization_coordsys_id, ), ) content = cur.fetchone() assert content[0] == organization_coordsys_id
def test_bad_config_geopackage_no_gpkg_contents(self): gpkg_file = os.path.join(test_config['base_dir'], 'cache.gpkg') table_name = 'no_gpkg_contents' with sqlite3.connect(gpkg_file) as db: cur = db.execute('''SELECT name FROM sqlite_master WHERE type='table' AND name=?''', (table_name,)) content = cur.fetchone() assert content[0] == table_name with sqlite3.connect(gpkg_file) as db: cur = db.execute('''SELECT table_name FROM gpkg_contents WHERE table_name=?''', (table_name,)) content = cur.fetchone() assert not content GeopackageCache(gpkg_file, TileGrid(srs=4326), table_name=table_name) with sqlite3.connect(gpkg_file) as db: cur = db.execute('''SELECT table_name FROM gpkg_contents WHERE table_name=?''', (table_name,)) content = cur.fetchone() assert content[0] == table_name