コード例 #1
0
    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)
コード例 #2
0
	def test_remove_board(self):
		#load shape test
		print "\n"
		print "---- debut test ----- "
		testPath = test_data_path('layer','aesn_simplifie.shp') 
		layer = load_layer(testPath)
		if not layer.isValid():
			print "-/-\- failed -/-\-"
		else:
			print "---- Layer loaded ----"
		 
		#Init a qgis instance
		registry = QgsMapLayerRegistry.instance()
		#Remove all layers
		registry.addMapLayer(layer)

		# Init the qt application to interact with each widget
		self.dialog = PlantMapDialog(IFACE)

		self.dialog.UI_taxonLayer.clear()
		self.dialog.UI_taxonLayer.addItem(layer.name(),layer)
		

		#Put a value of one field 
		self.dialog.UI_iterationField.clear()
		self.dialog.UI_iterationField.addItem("cd_ref_ref")

		iterationField = self.dialog.UI_iterationField.currentText()

		#Add one taxon to the board
		self.dialog.add_Taxon_To_Board("1234","test","OK")
		self.dialog.validate_remove_all()

		self.assertEqual(self.dialog.UI_taxonTab.rowCount(),0)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
    def test_remove_board(self):
        #load shape test
        print "\n"
        print "---- debut test ----- "
        testPath = test_data_path('layer', 'aesn_simplifie.shp')
        layer = load_layer(testPath)
        if not layer.isValid():
            print "-/-\- failed -/-\-"
        else:
            print "---- Layer loaded ----"

        #Init a qgis instance
        registry = QgsMapLayerRegistry.instance()
        #Remove all layers
        registry.addMapLayer(layer)

        # Init the qt application to interact with each widget
        self.dialog = PlantMapDialog(IFACE)

        self.dialog.UI_taxonLayer.clear()
        self.dialog.UI_taxonLayer.addItem(layer.name(), layer)

        #Put a value of one field
        self.dialog.UI_iterationField.clear()
        self.dialog.UI_iterationField.addItem("cd_ref_ref")

        iterationField = self.dialog.UI_iterationField.currentText()

        #Add one taxon to the board
        self.dialog.add_Taxon_To_Board("1234", "test", "OK")
        self.dialog.validate_remove_all()

        self.assertEqual(self.dialog.UI_taxonTab.rowCount(), 0)
コード例 #6
0
    def test39_OL3_base_group_only_included_when_base_map_selected(self):
        """OL3 Only include the 'Base maps' group when +1 base maps are selected"""

        layer_path = test_data_path('layer', 'point.shp')
        layer = load_layer(layer_path)

        registry = QgsMapLayerRegistry.instance()
        registry.addMapLayer(layer)

        dialog = MainDialog(IFACE)

        # Ensure the OpenLayers 3 option is selected
        dialog.ol3.click()

        # Ensure no base maps are selected
        for i in range(dialog.basemaps.count()):
            dialog.basemaps.item(i).setSelected(False)

        # Click the 'Update preview' button to ensure the preview URL is
        # updated
        QtTest.QTest.mouseClick(dialog.buttonPreview, Qt.LeftButton)

        test_layers_output = read_output(dialog.preview.url().toString(), 'layers/layers.js')
        assert "new ol.layer.Group" not in test_layers_output

        # Select a base map
        dialog.basemaps.item(0).setSelected(True)

        # Click the 'Update preview' button to ensure the preview URL is
        # updated
        QtTest.QTest.mouseClick(dialog.buttonPreview, Qt.LeftButton)

        test_layers_output = read_output(dialog.preview.url().toString(), 'layers/layers.js')
        assert "new ol.layer.Group" in test_layers_output
コード例 #7
0
    def test36_OL3_layer_list(self):
        """OL3 A layer list is present when selected"""

        layer_path = test_data_path('layer', 'point.shp')
        layer = load_layer(layer_path)

        registry = QgsMapLayerRegistry.instance()
        registry.addMapLayer(layer)

        dialog = MainDialog(IFACE)

        # Ensure the OpenLayers 3 option is selected
        dialog.ol3.click()

        # Check the 'Add layers list' checkbox
        dialog.items['Appearance'].get('Add layers list').setCheckState(1, QtCore.Qt.Checked)

        # Click the 'Update preview' button to ensure the preview URL is
        # updated
        QtTest.QTest.mouseClick(dialog.buttonPreview, Qt.LeftButton)

        test_qgis2web_output = read_output(dialog.preview.url().toString(), 'resources/qgis2web.js')
        assert 'new ol.control.LayerSwitcher' in test_qgis2web_output

        test_layers_output = read_output(dialog.preview.url().toString(), 'layers/layers.js')
        assert 'title: "point"' in test_layers_output
コード例 #8
0
    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)
コード例 #9
0
    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)
コード例 #10
0
    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)
コード例 #11
0
    def test_description_field(self):
        print "\n"
        print "----- debut test -----"

        testPath = test_data_path('layer', 'aesn_simplifie.shp')
        layer = load_layer(testPath)
        if not layer.isValid():
            print "-/-\- failed -/-\-"
        else:
            print "---- Layer loaded ----"

        #Init a qgis instance
        registry = QgsMapLayerRegistry.instance()
        #Remove all layers
        registry.addMapLayer(layer)

        # Init the qt application to interact with each widget
        self.dialog = PlantMapDialog(IFACE)

        self.dialog.UI_taxonLayer.clear()
        self.dialog.UI_taxonLayer.addItem(layer.name(), layer)

        #Put a value of one field
        self.dialog.UI_iterationField.clear()
        self.dialog.UI_iterationField.addItem("cd_ref_ref")

        #Put a value in the combobox of descriptionField
        self.dialog.UI_descriptionField.clear()
        self.dialog.UI_descriptionField.addItem("nom_comple")

        iterationField = self.dialog.UI_iterationField.currentText()
        descriptionField = self.dialog.UI_descriptionField.currentText()

        descriptionFeature = self.dialog.pme.check_taxon_id(
            "88949", layer, iterationField, descriptionField)

        self.assertEqual(descriptionFeature,
                         "Carex viridula Michx. subsp. viridula")

        self.dialog.add_Taxon_To_Board("88949", descriptionFeature, "OK")

        taxonBoard = self.dialog.UI_taxonTab
        cell = taxonBoard.item(0, 1).text()

        self.assertEqual("Carex viridula Michx. subsp. viridula", cell)
        self.assertNotEqual("fazfageaz fage", cell)
コード例 #12
0
	def test_description_field(self):
		print "\n"
		print "----- debut test -----"

		testPath = test_data_path('layer','aesn_simplifie.shp') 
		layer = load_layer(testPath)
		if not layer.isValid():
			print "-/-\- failed -/-\-"
		else:
			print "---- Layer loaded ----"

		#Init a qgis instance
		registry = QgsMapLayerRegistry.instance()
		#Remove all layers
		registry.addMapLayer(layer)

		# Init the qt application to interact with each widget
		self.dialog = PlantMapDialog(IFACE)

		self.dialog.UI_taxonLayer.clear()
		self.dialog.UI_taxonLayer.addItem(layer.name(),layer)

		#Put a value of one field 
		self.dialog.UI_iterationField.clear()
		self.dialog.UI_iterationField.addItem("cd_ref_ref")

		#Put a value in the combobox of descriptionField
		self.dialog.UI_descriptionField.clear()
		self.dialog.UI_descriptionField.addItem("nom_comple")

		iterationField = self.dialog.UI_iterationField.currentText()
		descriptionField = self.dialog.UI_descriptionField.currentText()		

		descriptionFeature = self.dialog.pme.check_taxon_id("88949",layer,iterationField,descriptionField)

		self.assertEqual(descriptionFeature,"Carex viridula Michx. subsp. viridula")

		self.dialog.add_Taxon_To_Board("88949",descriptionFeature,"OK")

		taxonBoard = self.dialog.UI_taxonTab
		cell = taxonBoard.item(0,1).text()
		
		self.assertEqual("Carex viridula Michx. subsp. viridula",cell)
		self.assertNotEqual("fazfageaz fage",cell)
コード例 #13
0
	def test_add_one_taxon(self):
		#self.dialog = PlantMapDialog(IFACE)

		#load shape test
		print "\n"
		print "---- debut test ----- "
		testPath = test_data_path('layer','aesn_simplifie.shp') 
		layer = load_layer(testPath)
		if not layer.isValid():
			print "-/-\- failed -/-\-"
		else:
			print "---- Layer loaded ----"
		 
		#Init a qgis instance
		registry = QgsMapLayerRegistry.instance()
		#Remove all layers
		registry.addMapLayer(layer)

		# Init the qt application to interact with each widget
		self.dialog = PlantMapDialog(IFACE)

		self.dialog.UI_taxonLayer.clear()
		self.dialog.UI_taxonLayer.addItem(layer.name(),layer)
		

		#Put a value of one field 
		self.dialog.UI_iterationField.clear()
		self.dialog.UI_iterationField.addItem("cd_ref_ref")

		iterationField = self.dialog.UI_iterationField.currentText()

		#Get the taxon board		
		taxonBoard = self.dialog.UI_taxonTab;

		#Add one taxon to the board
		self.dialog.add_Taxon_To_Board("1234","test","OK")

		#Test the tab length with a defined value
		self.assertEqual(taxonBoard.rowCount(),1)

		#Test the tab with the list which is supposed to be fill with the method
		self.assertEqual(taxonBoard.rowCount(),len(self.dialog.taxonList))
コード例 #14
0
    def test_add_one_taxon(self):
        #self.dialog = PlantMapDialog(IFACE)

        #load shape test
        print "\n"
        print "---- debut test ----- "
        testPath = test_data_path('layer', 'aesn_simplifie.shp')
        layer = load_layer(testPath)
        if not layer.isValid():
            print "-/-\- failed -/-\-"
        else:
            print "---- Layer loaded ----"

        #Init a qgis instance
        registry = QgsMapLayerRegistry.instance()
        #Remove all layers
        registry.addMapLayer(layer)

        # Init the qt application to interact with each widget
        self.dialog = PlantMapDialog(IFACE)

        self.dialog.UI_taxonLayer.clear()
        self.dialog.UI_taxonLayer.addItem(layer.name(), layer)

        #Put a value of one field
        self.dialog.UI_iterationField.clear()
        self.dialog.UI_iterationField.addItem("cd_ref_ref")

        iterationField = self.dialog.UI_iterationField.currentText()

        #Get the taxon board
        taxonBoard = self.dialog.UI_taxonTab

        #Add one taxon to the board
        self.dialog.add_Taxon_To_Board("1234", "test", "OK")

        #Test the tab length with a defined value
        self.assertEqual(taxonBoard.rowCount(), 1)

        #Test the tab with the list which is supposed to be fill with the method
        self.assertEqual(taxonBoard.rowCount(), len(self.dialog.taxonList))
コード例 #15
0
    def test37_OL3_base_layers_have_type_base(self):
        """OL3 Ensure base layers have a type property with a value of 'base'"""

        layer_path = test_data_path('layer', 'point.shp')
        layer = load_layer(layer_path)

        registry = QgsMapLayerRegistry.instance()
        registry.addMapLayer(layer)

        dialog = MainDialog(IFACE)

        # Ensure the OpenLayers 3 option is selected
        dialog.ol3.click()

        # Select a base map
        dialog.basemaps.item(0).setSelected(True)

        # Click the 'Update preview' button to ensure the preview URL is
        # updated
        QtTest.QTest.mouseClick(dialog.buttonPreview, Qt.LeftButton)

        test_layers_output = read_output(dialog.preview.url().toString(), 'layers/layers.js')
        assert "'type': 'base'" in test_layers_output