def test35_OL3_poly_graduated(self): """OL3 polygon graduated (test_qgis2web_dialog.test_OL3_poly_graduated)""" layer_path = test_data_path('layer', 'polygon.shp') style_path = test_data_path('style', 'json_polygon_graduated.qml') control_path = test_data_path('control', 'ol3_json_polygon_graduated.html') layer = load_layer(layer_path) layer.loadNamedStyle(style_path) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open(control_path, 'r') control_output = control_file.read() self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( "Extent", (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.ol3.click() test_file = open(self.dialog.preview.url().toString().replace( 'file://', '')) test_output = test_file.read() test_style_file = open(self.dialog.preview.url().toString().replace( 'file://', '').replace('index.html', 'styles/polygon_style.js')) test_style_output = test_style_file.read() test_output += test_style_output self.assertEqual(test_output, control_output)
def test26_Leaflet_wfs_poly_graduated(self): """Leaflet WFS polygon graduated (test_qgis2web_dialog.test_Leaflet_wfs_poly_graduated)""" layer_url = ('http://maps.nationalparks.gov.uk/geoserver/wfs?SERVICE' '=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME' '=yorkshire_dales:ydnpa_conservationareas&SRSNAME=EPSG' ':27700') layer_style = test_data_path('style', 'wfs_polygon_graduated.qml') control_path = test_data_path('control', 'leaflet_wfs_polygon_graduated.html') layer = load_wfs_layer(layer_url, 'polygon') layer.loadNamedStyle(layer_style) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open(control_path, 'r') control_output = control_file.read() self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( 'Extent', (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.leaflet.click() test_file = open(self.dialog.preview.url().toString().replace( "file://", "")) test_output = test_file.read() self.assertEqual(test_output, control_output)
def test25_Leaflet_json_poly_graduated(self): """Leaflet JSON polygon graduated (test_qgis2web_dialog.test_Leaflet_json_poly_graduated)""" layer_path = test_data_path('layer', 'polygon.shp') layer_style = test_data_path('style', 'json_polygon_graduated.qml') control_path = test_data_path('control', 'leaflet_json_polygon_graduated.html') layer = load_layer(layer_path) layer.loadNamedStyle(layer_style) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open(control_path, 'r') control_output = control_file.read() self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( 'Extent', (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.leaflet.click() test_file = open(self.dialog.preview.url().toString().replace( "file://", "")) test_output = test_file.read() self.assertEqual(test_output, control_output)
def tearDown(self): """Runs after each test""" registry = QgsMapLayerRegistry.instance() registry.removeAllMapLayers() self.dialog = MainDialog(IFACE) self.dialog.ol3.click() self.dialog = None
def test09_Leaflet_json_pnt_single(self): """Leaflet JSON point single (test_qgis2web_dialog.test_Leaflet_json_pnt_single)""" layer_path = test_data_path('layer', 'point.shp') style_path = test_data_path('style', 'point_single.qml') layer = load_layer(layer_path) layer.loadNamedStyle(style_path) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open( test_data_path('control', 'leaflet_json_point_single.html'), 'r') control_output = control_file.read() # Export to web map self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( 'Extent', (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.leaflet.click() # Open the test file test_file = open(self.dialog.preview.url().toString().replace( 'file://', '')) test_output = test_file.read() # Compare with control file self.assertEqual(test_output, control_output)
def run(self): if not self.dlg or sip.isdeleted(self.dlg): self.dlg = MainDialog(self.iface) self.dlg.setAttribute(Qt.WA_DeleteOnClose) self.dlg.show() # bring to front self.dlg.raise_()
def test10_Leaflet_wfs_pnt_single(self): """Leaflet WFS point single (test_qgis2web_dialog.test_Leaflet_wfs_pnt_single)""" layer_url = ('http://maps.nationalparks.gov.uk/geoserver/wfs?SERVICE' '=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=dartmoor' ':dnpa-tpo-point&SRSNAME=EPSG:27700') layer_style = test_data_path('style', 'point_single.qml') layer = load_wfs_layer(layer_url, 'point') layer.loadNamedStyle(layer_style) registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) control_file = open( test_data_path('control', 'leaflet_wfs_point_single.html'), 'r') control_output = control_file.read() self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( 'Extent', (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1) self.dialog.leaflet.click() test_file = open(self.dialog.preview.url().toString().replace( 'file://', '')) test_output = test_file.read() self.assertEqual(test_output, control_output)
def setUp(self): """Runs before each test""" self.dialog = MainDialog(IFACE) self.dialog.paramsTreeOL.itemWidget( self.dialog.paramsTreeOL.findItems( "Template", (Qt.MatchExactly | Qt.MatchRecursive))[0], 1).setCurrentIndex(1)
def run(self): dest_crs, poly = self.get_selected_polygons() is_new = False if not self.layer: if not poly: QMessageBox.critical(None, self.tr("Mask plugin error"), self.tr("No polygon selection !")) return self.layer = QgsVectorLayer( "MultiPolygon?crs=%s" % dest_crs.authid(), self.mask_name, "memory") style_tools.set_default_layer_symbology(self.layer) is_new = True self.parameters.layer = self.layer if self.must_reload_from_layer: self.layer = self.must_reload_from_layer self.parameters.load_from_layer(self.layer) self.must_reload_from_layer = None dlg = MainDialog(self.parameters, is_new) dlg.applied.connect(self.apply_mask_parameters) r = dlg.exec_() if r == 1: self.apply_mask_parameters() self.update_menus()
def test11_Leaflet_shp_poly_simple(self): """Leaflet shape polygon simple (test_qgis2web_dialog.test_Leaflet_shp_poly_simple).""" layer = QgsVectorLayer( "/home/travis/build/tomchadwin/qgis2web/test_data/polygon_feature.shp", "polygon feature", "ogr") if not layer: print "Layer failed to load!" registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) self.dialog = MainDialog(IFACE) self.dialog.leaflet.click()
def test09_Leaflet_shp_pnt_simple(self): """Leaflet shape point simple (test_qgis2web_dialog.test_Leaflet_shp_pnt_simple).""" layer = QgsVectorLayer( "/home/travis/build/tomchadwin/qgis2web/test_data/places_few_1.shp", "point feature", "ogr") if not layer: print "Layer failed to load!" registry = QgsMapLayerRegistry.instance() registry.addMapLayer(layer) testFile = open( '/home/travis/build/tomchadwin/qgis2web/test_data/shp_point_simple.html', 'r') goodOutput = testFile.read() self.dialog = MainDialog(IFACE) self.dialog.leaflet.click()
def run(self): appdef = None projFile = QgsProject.instance().fileName() if projFile: appdefFile = projFile + ".appdef" if os.path.exists(appdefFile): ret = QMessageBox.question( self.iface.mainWindow(), "Web app builder", "This project has been already published as a web app.\n" "Do you want to reload app configuration?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if ret == QMessageBox.Yes: appdef = loadAppdef(appdefFile) initialize() dlg = MainDialog(appdef) dlg.exec_()
def run(self): dlg = MainDialog(self.iface) dlg.exec_()
def test08_export_OL3(self): """Export OL3 - no data (test_qgis2web_dialog.test_export_OL3).""" self.dialog = MainDialog(IFACE) self.dialog.ol3.click() self.dialog.buttonExport.click()
def test07_preview_OL3(self): """Preview OL3 - no data (test_qgis2web_dialog.test_preview_OL3).""" self.dialog = MainDialog(IFACE) self.dialog.ol3.click() self.dialog.buttonPreview.click()
def test06_toggle_OL3(self): """Toggle to OL3 (test_qgis2web_dialog.test_toggle_OL3).""" self.dialog = MainDialog(IFACE) self.dialog.ol3.click()
def test05_export_Leaflet(self): """Export Leaflet - no data (test_qgis2web_dialog.test_export_Leaflet).""" self.dialog = MainDialog(IFACE) self.dialog.leaflet.click() self.dialog.buttonExport.click()
def test04_preview_Leaflet(self): """Preview Leaflet - no data (test_qgis2web_dialog.test_preview_Leaflet).""" self.dialog = MainDialog(IFACE) self.dialog.leaflet.click() self.dialog.buttonPreview.click()
def test03_toggle_Leaflet(self): """Toggle to Leaflet (test_qgis2web_dialog.test_toggle_Leaflet).""" self.dialog = MainDialog(IFACE) self.dialog.leaflet.click()
def test02_save_default(self): """Save default - no data (OL3) (test_qgis2web_dialog.test_save_default).""" self.dialog = MainDialog(IFACE) self.dialog.buttonExport.click()
def test01_preview_default(self): """Preview default - no data (OL3) (test_qgis2web_dialog.test_preview_default).""" self.dialog = MainDialog(IFACE) self.dialog.buttonPreview.click()
def run(self): dlg = MainDialog() dlg.exec_()
def run(self): dlg = MainDialog(self.iface) dlg.show()