diff --git a/tests/src/python/test_qgssymbollayer_readsld.py b/tests/src/python/test_qgssymbollayer_readsld.py index a8031019529..0c09f206941 100644 --- a/tests/src/python/test_qgssymbollayer_readsld.py +++ b/tests/src/python/test_qgssymbollayer_readsld.py @@ -28,12 +28,9 @@ import qgis # NOQA import os from qgis.testing import start_app, unittest from qgis.core import (QgsVectorLayer, - QgsProject, - QgsRectangle, - QgsMultiRenderChecker, - QgsSingleSymbolRenderer, - QgsFillSymbol, - QgsFeatureRequest + QgsFeature, + QgsGeometry, + QgsPoint ) from qgis.testing import unittest from qgis.testing.mocked import get_iface @@ -43,33 +40,50 @@ start_app() TEST_DATA_DIR = unitTestDataPath() +def createLayerWithOneLine(): + # create a temporary layer + # linelayer = iface.addVectorLayer("LineString?crs=epsg:4326&field=gid:int&field=name:string", "simple_line", "memory") + linelayer = QgsVectorLayer("LineString?crs=epsg:4326&field=gid:int&field=name:string", "simple_line", "memory") + one = QgsFeature(linelayer.dataProvider().fields(), 0) + one.setAttributes([1, 'one']) + one.setGeometry(QgsGeometry.fromPolyline([QgsPoint(-7, 38), QgsPoint(-8, 42)])) + linelayer.dataProvider().addFeatures([one]) + return linelayer + class TestQgsSymbolLayerReadSld(unittest.TestCase): """ - This class loads an SLD style and checks if the styling was properly applied + This class checks if SLD styles are properly applied """ def setUp(self): self.iface = get_iface() - myShpFile = os.path.join(TEST_DATA_DIR, 'streams.shp') - self.layer = QgsVectorLayer(myShpFile, 'streams', 'ogr') + + # test VALUE + # test VALUE + def test_Literal_within_CSSParameter(self): + layer = createLayerWithOneLine() mFilePath = os.path.join(TEST_DATA_DIR, 'symbol_layer/external_sld/simple_streams.sld') - self.layer.loadSldStyle(mFilePath) - self.props = self.layer.renderer().symbol().symbolLayers()[0].properties() + layer.loadSldStyle(mFilePath) + props = layer.renderer().symbol().symbolLayers()[0].properties() - def testLineColor(self): - # stroke CSSParameter within ogc:Literal - # expected color is #003EBA, RGB 0,62,186 - self.assertEqual(self.layer.renderer().symbol().symbolLayers()[0].color().name(), '#003eba') + def testLineColor(): + # stroke CSSParameter within ogc:Literal + # expected color is #003EBA, RGB 0,62,186 + self.assertEqual(layer.renderer().symbol().symbolLayers()[0].color().name(), '#003eba') - def testLineWidth(self): - # stroke-width CSSParameter within ogc:Literal - self.assertEqual(self.props['line_width'], '2') + def testLineWidth(): + # stroke-width CSSParameter within ogc:Literal + self.assertEqual(props['line_width'], '2') - def testLineOpacity(self): - # stroke-opacity CSSParameter NOT within ogc:Literal - # stroke-opacity=0.1 - self.assertEqual(self.props['line_color'], '0,62,186,25') + def testLineOpacity(): + # stroke-opacity CSSParameter NOT within ogc:Literal + # stroke-opacity=0.1 + self.assertEqual(props['line_color'], '0,62,186,25') + + testLineColor() + testLineWidth() + testLineOpacity() if __name__ == '__main__': unittest.main() diff --git a/tests/testdata/streams.dbf b/tests/testdata/streams.dbf deleted file mode 100644 index 2bb3c53067e..00000000000 Binary files a/tests/testdata/streams.dbf and /dev/null differ diff --git a/tests/testdata/streams.prj b/tests/testdata/streams.prj deleted file mode 100644 index 94024524a8e..00000000000 --- a/tests/testdata/streams.prj +++ /dev/null @@ -1 +0,0 @@ -PROJCS["NAD27 / UTM zone 13N", GEOGCS["NAD27", DATUM["North American Datum 1927", SPHEROID["Clarke 1866", 6378206.4, 294.9786982138982, AUTHORITY["EPSG","7008"]], TOWGS84[-4.2, 135.4, 181.9, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6267"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4267"]], PROJECTION["Transverse Mercator", AUTHORITY["EPSG","9807"]], PARAMETER["central_meridian", -105.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.9996], PARAMETER["false_easting", 500000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","26713"]] \ No newline at end of file diff --git a/tests/testdata/streams.shp b/tests/testdata/streams.shp deleted file mode 100644 index 411d0758f31..00000000000 Binary files a/tests/testdata/streams.shp and /dev/null differ diff --git a/tests/testdata/streams.shx b/tests/testdata/streams.shx deleted file mode 100644 index 2784dfe301c..00000000000 Binary files a/tests/testdata/streams.shx and /dev/null differ