mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Merge pull request #34904 from elpaso/pgraster-test-fix
Try to make PG raster test more robust
This commit is contained in:
commit
1773270f69
@ -66,8 +66,19 @@ class TestPyQgsPostgresRasterProvider(unittest.TestCase):
|
||||
cls.dbconn = 'service=qgis_test'
|
||||
if 'QGIS_PGTEST_DB' in os.environ:
|
||||
cls.dbconn = os.environ['QGIS_PGTEST_DB']
|
||||
# Create test layers
|
||||
|
||||
cls._load_test_table('public', 'raster_tiled_3035')
|
||||
cls._load_test_table('public', 'raster_3035_no_constraints')
|
||||
cls._load_test_table('public', 'raster_3035_tiled_no_overviews')
|
||||
cls._load_test_table('public', 'raster_3035_tiled_no_pk')
|
||||
cls._load_test_table('public', 'raster_3035_tiled_composite_pk')
|
||||
cls._load_test_table('public', 'raster_3035_untiled_multiple_rows')
|
||||
cls._load_test_table('idro', 'cosmo_i5_snow', 'bug_34823_pg_raster')
|
||||
|
||||
# Fix timing issues in backend
|
||||
#time.sleep(1)
|
||||
|
||||
# Create test layer
|
||||
cls.rl = QgsRasterLayer(cls.dbconn + ' sslmode=disable key=\'rid\' srid=3035 table="public"."raster_tiled_3035" sql=', 'test', 'postgresraster')
|
||||
assert cls.rl.isValid()
|
||||
cls.source = cls.rl.dataProvider()
|
||||
@ -118,21 +129,18 @@ class TestPyQgsPostgresRasterProvider(unittest.TestCase):
|
||||
def testNoConstraintRaster(self):
|
||||
"""Read unconstrained raster layer"""
|
||||
|
||||
self._load_test_table('public', 'raster_3035_no_constraints')
|
||||
rl = QgsRasterLayer(self.dbconn + ' sslmode=disable key=\'pk\' srid=3035 table="public"."raster_3035_no_constraints" sql=', 'test', 'postgresraster')
|
||||
self.assertTrue(rl.isValid())
|
||||
|
||||
def testPkGuessing(self):
|
||||
"""Read raster layer with no pkey in uri"""
|
||||
|
||||
self._load_test_table('public', 'raster_tiled_3035')
|
||||
rl = QgsRasterLayer(self.dbconn + ' sslmode=disable srid=3035 table="public"."raster_tiled_3035" sql=', 'test', 'postgresraster')
|
||||
self.assertTrue(rl.isValid())
|
||||
|
||||
def testWhereCondition(self):
|
||||
"""Read raster layer with where condition"""
|
||||
|
||||
self._load_test_table('public', 'raster_3035_tiled_no_overviews')
|
||||
rl_nowhere = QgsRasterLayer(self.dbconn + ' sslmode=disable srid=3035 table="public"."raster_3035_tiled_no_overviews"' +
|
||||
'sql=', 'test', 'postgresraster')
|
||||
self.assertTrue(rl_nowhere.isValid())
|
||||
@ -162,7 +170,6 @@ class TestPyQgsPostgresRasterProvider(unittest.TestCase):
|
||||
def testNoPk(self):
|
||||
"""Read raster with no PK"""
|
||||
|
||||
self._load_test_table('public', 'raster_3035_tiled_no_pk')
|
||||
rl = QgsRasterLayer(self.dbconn + ' sslmode=disable srid=3035 table="public"."raster_3035_tiled_no_pk"' +
|
||||
'sql=', 'test', 'postgresraster')
|
||||
self.assertTrue(rl.isValid())
|
||||
@ -170,7 +177,6 @@ class TestPyQgsPostgresRasterProvider(unittest.TestCase):
|
||||
def testCompositeKey(self):
|
||||
"""Read raster with composite pks"""
|
||||
|
||||
self._load_test_table('public', 'raster_3035_tiled_composite_pk')
|
||||
rl = QgsRasterLayer(self.dbconn + ' sslmode=disable srid=3035 table="public"."raster_3035_tiled_composite_pk"' +
|
||||
'sql=', 'test', 'postgresraster')
|
||||
self.assertTrue(rl.isValid())
|
||||
@ -235,8 +241,6 @@ class TestPyQgsPostgresRasterProvider(unittest.TestCase):
|
||||
"""Test that a layer in a different schema than public can be loaded
|
||||
See: GH #34823"""
|
||||
|
||||
self._load_test_table('idro', 'cosmo_i5_snow', 'bug_34823_pg_raster')
|
||||
|
||||
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema}".format(table='cosmo_i5_snow', schema='idro'), 'pg_layer', 'postgresraster')
|
||||
self.assertTrue(rl.isValid())
|
||||
self.assertTrue(compareWkt(rl.extent().asWktPolygon(), 'POLYGON((-64.79286766849691048 -77.26689086732433509, -62.18292922825105506 -77.26689086732433509, -62.18292922825105506 -74.83694818157819384, -64.79286766849691048 -74.83694818157819384, -64.79286766849691048 -77.26689086732433509))'))
|
||||
@ -244,8 +248,6 @@ class TestPyQgsPostgresRasterProvider(unittest.TestCase):
|
||||
def testUntiledMultipleRows(self):
|
||||
"""Test multiple rasters (one per row)"""
|
||||
|
||||
self._load_test_table('public', 'raster_3035_untiled_multiple_rows')
|
||||
|
||||
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} sql=\"pk\" = 1".format(table='raster_3035_untiled_multiple_rows', schema='public'), 'pg_layer', 'postgresraster')
|
||||
self.assertTrue(rl.isValid())
|
||||
block = rl.dataProvider().block(1, rl.extent(), 2, 2)
|
||||
@ -267,8 +269,6 @@ class TestPyQgsPostgresRasterProvider(unittest.TestCase):
|
||||
def testSetSubsetString(self):
|
||||
"""Test setSubsetString"""
|
||||
|
||||
self._load_test_table('public', 'raster_3035_untiled_multiple_rows')
|
||||
|
||||
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} sql=\"pk\" = 2".format(table='raster_3035_untiled_multiple_rows', schema='public'), 'pg_layer', 'postgresraster')
|
||||
self.assertTrue(rl.isValid())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user