def testRendererSavedToProject(self):
     """Test that renderer correctly saved in the project"""
     projfile = os.path.join(os.path.dirname(__file__), "data", "project.qgs")
     iface.addProject(projfile)
     layer = layerFromName("2525")
     renderer = MilStd2525Renderer(50, "SDIC")
     layer.setRendererV2(renderer)
     newProjectFile = tempFilename("qgs")
     proj=QgsProject.instance()
     proj.write(QFileInfo(newProjectFile))
     iface.newProject()
     iface.addProject(newProjectFile)
     layer = layerFromName("2525")
     layerRenderer = layer.rendererV2()
     self.assertEquals("MilStd2525Renderer", layerRenderer.type())
def _modifyFeature():
    layer = layerFromName("points")
    feature = layer.getFeatures().next()
    fid = feature.id()
    layer.startEditing()
    layer.changeAttributeValue(fid, 0, "100")
    layer.commitChanges()
 def _setRenderer():
     r = MilStd2525Renderer(40, "SDIC")
     layer = layerFromName("2525")
     layer.setRendererV2(r)
     layer.reload()
     layer.triggerRepaint()
     iface.mapCanvas().setExtent(layer.extent())
def _addFeature():
    layer = layerFromName("points")
    feat = QgsFeature(layer.pendingFields())
    feat.setAttributes(["5", str(uuid.uuid4())])
    layer.startEditing()
    feat.setGeometry(QgsGeometry.fromPoint(QgsPoint(123, 456)))
    layer.addFeatures([feat])
    layer.commitChanges()
示例#5
0
    def testLayerFromName(self):
        """check if giving a layer name it's instance is returned."""
        # test 1: not layer is present
        layer = layerFromName('testFile2')
        self.assertIsNone(layer)

        # preconditions
        QgsMapLayerRegistry.instance().addMapLayer(self.testFile1)
        QgsMapLayerRegistry.instance().addMapLayer(self.testFile2)
        QgsMapLayerRegistry.instance().addMapLayer(self.testFile3)
        # do test 2: look for the 'testFile2' that exists
        layer = layerFromName('testFile2')
        self.assertEqual(self.testFile2, layer)

        # do test 3: look for the 'unexist' that does not exists
        layer = layerFromName('unexist')
        self.assertIsNone(layer)
def _checkLayerNotInRepo():
    layer = layerFromName("points")
    tracking = getTrackingInfo(layer)
    assert tracking is None
    connector = PyQtConnectorDecorator()
    connector.checkIsAlive()
    repo =  Repository(os.path.join(_tempReposPath, "repos", "pointsrepo"), connector)
    layers = [tree.path for tree in repo.trees]
    assert "points" not in layers
def _checkFeatureModifiedInRepo():
    connector = PyQtConnectorDecorator()
    connector.checkIsAlive()
    repo =  Repository(os.path.join(_tempReposPath, "repos", "repo"), connector)
    diffs = repo.diff("master", Commitish(repo, "master").parent.ref)
    assert 1 == len(diffs)
    layer = layerFromName("points")
    feature = layer.getFeatures().next()
    geogigid = str(feature[1])
    assert "points/" + geogigid == diffs[0].path
def _checkLayerInRepo():
    layer = layerFromName("points")
    tracking = getTrackingInfo(layer)
    assert tracking is not None
    connector = PyQtConnectorDecorator()
    connector.checkIsAlive()
    repo =  Repository(tracking.repoFolder, connector)
    layers = [tree.path for tree in repo.trees]
    assert "points" in layers
    removeTrackedLayer(layer)
def _openAndUpload():
    _loadTestData()
    layer = layerFromName("qgis_plugin_test_pt1")
    cat = _setUpCatalogAndWorkspace()
    catWrapper = CatalogWrapper(cat)
    catWrapper.publishLayer(layer, "test_workspace", True)
    stores = cat.get_stores("test_workspace")
    assert len(stores) != 0
    url = 'url=http://localhost:8080/geoserver/wms&format=image/png&layers=test_workspace:qgis_plugin_test_pt1&styles=qgis_plugin_test_pt1&crs=EPSG:4326'
    wmsLayer = QgsRasterLayer(url, "WMS", 'wms')
    assert wmsLayer.isValid()
    QgsMapLayerRegistry.instance().addMapLayer(wmsLayer)
 def _stopEditing():
     layer = layerFromName("2525")
     layer.rollBack()
     iface.newProject()
示例#11
0
def _checkContextMenuInfo(text):
    layer = layerFromName("points")
    actions = layer.infoActions
    assert 2 == len(actions)
    assert text in actions[0].text().lower()
 def _changeSize():
     layer = layerFromName("2525")
     r = layer.rendererV2()
     r.size = 80
     layer.triggerRepaint()
示例#13
0
def _checkLayerHasUntrackedContextMenus():
    layer = layerFromName("points")
    actions = layer.geogigActions
    assert 1 == len(actions)
    assert "add" in actions[0].text().lower()
示例#14
0
def _checkLayerHasTrackedContextMenus():
    layer = layerFromName("points")
    actions = layer.geogigActions
    assert 1 < len(actions)
    assert "version id" in actions[-1].text().lower()
示例#15
0
def _selectLayer():
    layer = layerFromName("points")
    iface.setActiveLayer(layer)
示例#16
0
def _checkLayerInProject():
    layer = layerFromName("points")
    assert layer is not None
def _checkLayerInProject():
    layer = layerFromName("points")
    assert layer is not None
 def _startEditing():
     layer = layerFromName("2525")
     layer.startEditing()
def _checkLayerHasTrackedContextMenus():
    layer = layerFromName("points")
    actions = layer.geogigActions
    assert 2 == len(actions)
    assert "remove" in actions[0].text().lower()
 def _openLayerProperties():
     layer = layerFromName("2525")
     iface.showLayerProperties(layer)
 def _openAttributesTable():
     layer = layerFromName("2525")
     iface.showAttributeTable(layer)