Run raster provider test on gdal source

This commit is contained in:
Nyall Dawson 2025-02-11 11:14:06 +10:00
parent 87ab35b05a
commit a30311e18b
2 changed files with 25 additions and 2 deletions

View File

@ -22,7 +22,7 @@ class RasterProviderTestCase:
Test property values for a provider which does not have the
fixed size capability
"""
l = self.get_layer("fixed_size")
l = self.get_layer("not_fixed_size")
if l.dataProvider().capabilities() & Qgis.RasterInterfaceCapability.Size:
return
@ -33,6 +33,23 @@ class RasterProviderTestCase:
self.assertEqual(l.rasterUnitsPerPixelX(), 1)
self.assertEqual(l.rasterUnitsPerPixelY(), 1)
def test_fixed_size_provider(self):
"""
Test property values for a provider which does has the
fixed size capability
"""
l = self.get_layer("fixed_size")
if not l.dataProvider().capabilities() & Qgis.RasterInterfaceCapability.Size:
return
# TODO -- adjust these values after we've got a generic "reference" fixed size
# raster which is appropriate for these tests
self.assertEqual(l.width(), 3)
self.assertEqual(l.height(), 4)
# and 1 for raster units per pixel
self.assertAlmostEqual(l.rasterUnitsPerPixelX(), 0.000642531091049392, 8)
self.assertAlmostEqual(l.rasterUnitsPerPixelY(), 0.00048366498497820487, 8)
def test_provider_clone(self):
"""
Test that cloning layer works

View File

@ -27,6 +27,7 @@ import unittest
from qgis.testing import start_app, QgisTestCase
from utilities import unitTestDataPath
from raster_provider_test_base import RasterProviderTestCase
start_app()
TEST_DATA_DIR = unitTestDataPath()
@ -36,7 +37,12 @@ def GDAL_COMPUTE_VERSION(maj, min, rev):
return (maj) * 1000000 + (min) * 10000 + (rev) * 100
class PyQgsGdalProvider(QgisTestCase):
class PyQgsGdalProvider(QgisTestCase, RasterProviderTestCase):
def get_layer(self, test_id: str) -> QgsRasterLayer:
return QgsRasterLayer(
self.get_test_data_path("landsat_4326.tif").as_posix(), test_id
)
def checkBlockContents(self, block, expected):
res = []