예제 #1
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)
예제 #2
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)
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
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)
예제 #7
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)
예제 #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 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)
예제 #10
0
    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)
예제 #11
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)
예제 #12
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
 def test_parse_xml(self):
     """Test parsing the xml works correctly."""
     xml_path = test_data_path('collections', 'test_collection', 'symbol',
                               'various_symbols.xml')
     extractor = SymbolXMLExtractor(xml_path)
     # There are 9 symbols and 3 colorramps there
     expected_symbols = {
         'fill_raster': QgsFillSymbolV2,
         'fill_svg': QgsFillSymbolV2,
         'fill_svg_line': QgsFillSymbolV2,
         'line_arrow': QgsLineSymbolV2,
         'line_svg_marker': QgsLineSymbolV2,
         'marker_ellipse': QgsMarkerSymbolV2,
         'marker_font': QgsMarkerSymbolV2,
         'marker_simple': QgsMarkerSymbolV2,
         'marker_svg': QgsMarkerSymbolV2
     }
     self.assertEqual(len(extractor.symbols), len(expected_symbols))
     for symbol in extractor.symbols:
         self.assertTrue(
             isinstance(symbol['symbol'], expected_symbols[symbol['name']]))
     expected_colorramps = {
         'cr_colorbrewer': QgsVectorColorBrewerColorRampV2,
         'cr_gradient': QgsVectorGradientColorRampV2,
         'cr_random': QgsVectorRandomColorRampV2
     }
     self.assertEqual(len(extractor.colorramps), len(expected_colorramps))
     for colorramp in extractor.colorramps:
         self.assertTrue(
             isinstance(colorramp['colorramp'],
                        expected_colorramps[colorramp['name']]))
예제 #14
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
예제 #15
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)
예제 #16
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)
    def test_parsing_csv_file(self):
        # Init the qt application to interact with each widget
        self.dialog = PlantMapDialog(IFACE)
        testPath = test_data_path('test.csv')
        countRow = 0
        taxonsLocal = []
        with open(testPath, 'r') as csvfile:
            spamreader = csv.reader(csvfile, delimiter=',', quotechar='"')
            for row in spamreader:
                countRow += 1
                taxonsLocal.append(row[0])

        taxons = self.dialog.parsing_csv_file(testPath)
        self.assertEqual(len(taxons), countRow)

        compare = lambda x, y: collections.Counter(x) == collections.Counter(y)

        self.assertTrue(compare)
예제 #18
0
	def test_parsing_csv_file(self):
		# Init the qt application to interact with each widget
		self.dialog = PlantMapDialog(IFACE)
		testPath = test_data_path('test.csv') 
		countRow = 0
		taxonsLocal=[]
		with open(testPath, 'r') as csvfile:
			spamreader = csv.reader(csvfile, delimiter=',', quotechar='"')
			for row in spamreader:
				countRow+=1
				taxonsLocal.append(row[0])

		taxons = self.dialog.parsing_csv_file(testPath)
		self.assertEqual(len(taxons),countRow)

		compare = lambda x,y:collections.Counter(x) == collections.Counter(y)
		
		self.assertTrue(compare)
예제 #19
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)
예제 #20
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))
예제 #21
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))
예제 #22
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