def openTestProject(name): orgPath = os.path.join(os.path.dirname(__file__), "data", "projects", name) destPath = tempSubfolder() shutil.copytree(orgPath, destPath) projectFile = os.path.join(destPath, name + ".qgs") if projectFile != QgsProject.instance().fileName(): iface.addProject(projectFile)
def _testOLApp(project): projectFile = os.path.join(os.path.dirname(__file__), "data", "%s.qgs" % project) iface.addProject(projectFile) folder = tempfile.mkdtemp() mapboxgl.projectToMapbox(folder, True) path = os.path.join(folder, "index.html") webbrowser.open("file://" + path)
def openTestProject(name): orgPath = os.path.join(os.path.dirname(__file__), "data", "projects", name) destPath = tempFolderInTempFolder() copy_tree(orgPath, destPath) projectFile = os.path.join(destPath, name + ".qgs") if projectFile != QgsProject.instance().fileName(): iface.addProject(projectFile)
def openProject(projectFile): folder = os.path.dirname(projectFile) projectName = os.path.basename(projectFile) tempDir = os.path.join(QDir.tempPath(), 'lessons' , 'lesson' + str(time.time())) dest = os.path.abspath(tempDir) shutil.copytree(folder, dest) tempProjectFile = os.path.join(dest, projectName) iface.addProject(tempProjectFile)
def setUpClass(cls): ''' 'test' workspace cannot exist in the test catalog''' cls.cat = utils.getGeoServerCatalog() utils.cleanCatalog(cls.cat.catalog) cls.cat.catalog.create_workspace(WORKSPACE, "http://geoserver.com") cls.ws = cls.cat.catalog.get_workspaces(WORKSPACE)[0] projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") iface.addProject(projectFile)
def openProject(projectFile): folder = os.path.dirname(projectFile) projectName = os.path.basename(projectFile) tempDir = os.path.join(QDir.tempPath(), "lessons", "lesson{}".format(str(time.time()))) dest = os.path.abspath(tempDir) shutil.copytree(folder, dest) tempProjectFile = os.path.join(dest, projectName) iface.addProject(tempProjectFile)
def setUpClass(cls): ''' 'test' workspace cannot exist in the test catalog''' cls.cat = utils.getGeoServerCatalog() utils.cleanCatalog(cls.cat.catalog) cls.cat.catalog.create_workspace(WORKSPACE, "http://geoserver.com") cls.ws = cls.cat.catalog.get_workspaces(WORKSPACE)[0] projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test_font.qgs") iface.addProject(projectFile)
def setUpClass(cls): cls.explorer = GeoServerExplorer() cls.cat = Catalog("http://"+geoserverLocation()+"/geoserver/rest", "admin", "geoserver") cleanCatalog(cls.cat) cls.cat.create_workspace(WORKSPACE, "http://test1.com") cls.cat.create_workspace(WORKSPACEB, "http://test2.com") # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase(QgsProject.instance().fileName()): iface.addProject(projectFile)
def setUpClass(cls): cls.explorer = GeoServerExplorer() cls.catWrapper = getGeoServerCatalog() cls.cat = cls.catWrapper.catalog cleanCatalog(cls.cat) cls.cat.create_workspace(WORKSPACE, "http://test1.com") cls.cat.create_workspace(WORKSPACEB, "http://test2.com") # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") iface.addProject(projectFile)
def setUpClass(cls): ''' 'test' workspace cannot exist in the test catalog''' cls.cat = utils.getGeoServerCatalog() utils.cleanCatalog(cls.cat.catalog) cls.cat.catalog.create_workspace(WORKSPACE, "http://geoserver.com") cls.ws = cls.cat.catalog.get_workspace(WORKSPACE) assert cls.ws is not None projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase(QgsProject.instance().fileName()): iface.addProject(projectFile)
def setUpClass(cls): cls.explorer = GeoServerExplorer() cls.cat = Catalog("http://localhost:8080/geoserver/rest", "admin", "geoserver") cleanCatalog(cls.cat) cls.cat.create_workspace(WORKSPACE, "http://test1.com") cls.cat.create_workspace(WORKSPACEB, "http://test2.com") # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase(QgsProject.instance().fileName()): iface.addProject(projectFile)
def setUpClass(cls): ''' 'test' workspace cannot exist in the test catalog''' cls.cat = utils.getGeoServerCatalog() utils.cleanCatalog(cls.cat.catalog) cls.cat.catalog.create_workspace(WORKSPACE, "http://geoserver.com") cls.ws = cls.cat.catalog.get_workspace(WORKSPACE) assert cls.ws is not None projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase( QgsProject.instance().fileName()): iface.addProject(projectFile)
def load_project(name): """ Load a project from the set project paths """ _name = name name += ".qgs" for path in project_paths: for root, dirs, files in os.walk(path): if name in files: path = os.path.join(root, name) iface.addProject(path) return iface.addProject(_name)
def setUpClass(cls): # do workspace popuplation super(DeleteTests, cls).setUpClass() cls.ws = cls.cat.get_workspaces(WORKSPACE)[0] # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase(QgsProject.instance().fileName()): iface.addProject(projectFile) # set flags to instruct GUI interaction cls.confirmDelete = pluginSetting("ConfirmDelete") setPluginSetting("ConfirmDelete", False)
def testRoundTripLines(): projectFile = os.path.join(os.path.dirname(__file__), "data", "testlines.qgs") iface.addProject(projectFile) layerA = processing.getObject("lines") folder = tempfile.mkdtemp() styles = mapboxgl.projectToMapbox(folder) layerA2 =dataobjects.load(layerA.source(), "lines2") mapboxgl.setLayerSymbologyFromMapboxStyle(layerA2, styles["layers"][0]) layerB2 =dataobjects.load(layerA.source(), "linesb2") mapboxgl.setLayerSymbologyFromMapboxStyle(layerB2, styles["layers"][1]) layerC2 =dataobjects.load(layerA.source(), "linesc2") mapboxgl.setLayerSymbologyFromMapboxStyle(layerC2, styles["layers"][2]) shutil.rmtree(folder, ignore_errors=True)
def setUpClass(cls): # do workspace popuplation super(DeleteTests, cls).setUpClass() cls.ws = cls.cat.get_workspace(WORKSPACE) assert cls.ws is not None # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase(QgsProject.instance().fileName()): iface.addProject(projectFile) # set flags to instruct GUI interaction cls.confirmDelete = QSettings().value("/GeoServer/Settings/General/ConfirmDelete", True, bool) QSettings().setValue("/GeoServer/Settings/General/ConfirmDelete", False)
def setUpClass(cls): cls.explorer = GeoServerExplorer() cls.catWrapper = utils.getGeoServerCatalog() cls.cat = cls.catWrapper.catalog utils.populateCatalog(cls.cat) cls.catalogItem = GsCatalogItem(cls.cat, "catalog") cls.explorer.explorerTree.gsItem.addChild(cls.catalogItem) cls.catalogItem.populate() cls.tree = cls.explorer.tree # @TODO - make tests pass using importer cls.useRestApi = QSettings().setValue("/GeoServer/Settings/GeoServer/UseRestApi", True) projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase(QgsProject.instance().fileName()): iface.addProject(projectFile)
def open_project(self): if not self.path: return qgis_files = find_qgis_files(self.path) if len(qgis_files) == 1: iface.addProject(qgis_files[0]) else: msg = "Selected project does not contain any QGIS project file" if len( qgis_files ) == 0 else "Plugin can only load project with single QGIS project file but {} found.".format( len(qgis_files)) QMessageBox.warning(None, 'Load QGIS project', msg, QMessageBox.Close)
def setUpClass(cls): # do workspace popuplation super(DeleteTests, cls).setUpClass() cls.ws = cls.cat.get_workspaces(WORKSPACE)[0] # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase( QgsProject.instance().fileName()): iface.addProject(projectFile) # set flags to instruct GUI interaction cls.confirmDelete = pluginSetting("ConfirmDelete") setPluginSetting("ConfirmDelete", False)
def setUpClass(cls): cls.explorer = GeoServerExplorer() # reasize if in PKI auth context if hasattr(cls, 'authm') and cls.authm: cls.catWrapper = getGeoServerCatalog(authcfgid=AUTHCFGID, authtype=AUTHTYPE) else: cls.catWrapper = getGeoServerCatalog() cls.cat = cls.catWrapper.catalog cleanCatalog(cls.cat) cls.cat.create_workspace(WORKSPACE, "http://test1.com") cls.cat.create_workspace(WORKSPACEB, "http://test2.com") # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") iface.addProject(projectFile)
def setUpClass(cls): cls.explorer = GeoServerExplorer() # Disable cache cls.cache_time = pluginSetting("AuthCatalogXMLCacheTime") setPluginSetting("AuthCatalogXMLCacheTime", 1) cls.catWrapper = utils.getGeoServerCatalog() cls.cat = cls.catWrapper.catalog utils.populateCatalog(cls.cat) cls.catalogItem = GsCatalogItem(cls.cat, "catalog") cls.explorer.explorerTree.gsItem.addChild(cls.catalogItem) cls.catalogItem.populate() cls.tree = cls.explorer.tree projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") iface.addProject(projectFile)
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, "SIDC") layer.setRenderer(renderer) newProjectFile = tempFilename("qgs") # noinspection PyArgumentList proj = QgsProject.instance() proj.write(newProjectFile) iface.newProject() iface.addProject(newProjectFile) layer = _layerFromName("2525") layerRenderer = layer.renderer() self.assertEquals("MilStd2525Renderer", layerRenderer.type())
def setUpClass(cls): cls.explorer = GeoServerExplorer() # check if context is a PKI auth context if hasattr(cls, 'authm') and cls.authm: cls.catWrapper = utils.getGeoServerCatalog(authcfgid=AUTHCFGID, authtype=AUTHTYPE) else: cls.catWrapper = utils.getGeoServerCatalog() cls.cat = cls.catWrapper.catalog utils.populateCatalog(cls.cat) cls.catalogItem = GsCatalogItem(cls.cat, "catalog") cls.explorer.explorerTree.gsItem.addChild(cls.catalogItem) cls.catalogItem.populate() cls.tree = cls.explorer.tree # @TODO - make tests pass using importer cls.useRestApi = QSettings().setValue("/GeoServer/Settings/GeoServer/UseRestApi", True) projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") iface.addProject(projectFile)
def setUpClass(cls): ''' 'test' workspace cannot exist in the test catalog''' # setup auth configuration os.environ['QGIS_AUTH_DB_DIR_PATH'] = AUTH_TESTDATA cls.authm = QgsAuthManager.instance() msg = 'Failed to verify master password in auth db' assert cls.authm.setMasterPassword(AUTHDB_MASTERPWD, True), msg # connect and prepare pki catalog cls.cat = utils.getGeoServerCatalog(authcfgid=AUTHCFGID, authtype=AUTHTYPE) utils.cleanCatalog(cls.cat.catalog) cls.cat.catalog.create_workspace(WORKSPACE, "http://geoserver.com") cls.ws = cls.cat.catalog.get_workspace(WORKSPACE) assert cls.ws is not None projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase(QgsProject.instance().fileName()): iface.addProject(projectFile)
def setUpClass(cls): cls.explorer = GeoServerExplorer() cls.catWrapper = utils.getGeoServerCatalog() cls.cat = cls.catWrapper.catalog utils.populateCatalog(cls.cat) cls.catalogItem = GsCatalogItem(cls.cat, "catalog") cls.explorer.explorerTree.gsItem.addChild(cls.catalogItem) cls.catalogItem.populate() cls.tree = cls.explorer.tree # @TODO - make tests pass using importer cls.useRestApi = QSettings().setValue( "/GeoServer/Settings/GeoServer/UseRestApi", True) projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase( QgsProject.instance().fileName()): iface.addProject(projectFile)
def setUpClass(cls): # do workspace popuplation super(DeleteTests, cls).setUpClass() cls.ws = cls.cat.get_workspace(WORKSPACE) assert cls.ws is not None # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase( QgsProject.instance().fileName()): iface.addProject(projectFile) # set flags to instruct GUI interaction cls.confirmDelete = QSettings().value( "/GeoServer/Settings/General/ConfirmDelete", True, bool) QSettings().setValue("/GeoServer/Settings/General/ConfirmDelete", False)
def setUpClass(cls): ''' 'test' workspace cannot exist in the test catalog''' # setup auth configuration utils.initAuthManager() utils.populatePKITestCerts() # connect and prepare pki catalog cls.cat = utils.getGeoServerCatalog(authcfgid=utils.AUTHCFGID, authtype=utils.AUTHTYPE) utils.cleanCatalog(cls.cat.catalog) cls.cat.catalog.create_workspace(utils.WORKSPACE, "http://geoserver.com") cls.ws = cls.cat.catalog.get_workspace(utils.WORKSPACE) assert cls.ws is not None projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if (os.path.normcase(projectFile) != os.path.normcase(QgsProject.instance().fileName())): iface.addProject(projectFile)
def setUpClass(cls): cls.explorer = GeoServerExplorer() # reasize if in PKI auth context # import is doen here to avoid to have the effect to loose module # this fixes https://github.com/boundlessgeo/qgis-geoserver-plugin/issues/85 from geoserverexplorer.test.utils import AUTHCFGID, AUTHTYPE, AUTHM if AUTHM: cls.catWrapper = getGeoServerCatalog(authcfgid=AUTHCFGID, authtype=AUTHTYPE) else: cls.catWrapper = getGeoServerCatalog() cls.cat = cls.catWrapper.catalog cleanCatalog(cls.cat) cls.cat.create_workspace(WORKSPACE, "http://test1.com") cls.cat.create_workspace(WORKSPACEB, "http://test2.com") # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") iface.addProject(projectFile)
def setUpClass(cls): ''' 'test' workspace cannot exist in the test catalog''' # setup auth configuration utils.initAuthManager() utils.populatePKITestCerts() # connect and prepare pki catalog cls.cat = utils.getGeoServerCatalog(authcfgid=utils.AUTHCFGID, authtype=utils.AUTHTYPE) utils.cleanCatalog(cls.cat.catalog) cls.cat.catalog.create_workspace(utils.WORKSPACE, "http://geoserver.com") cls.ws = cls.cat.catalog.get_workspace(utils.WORKSPACE) assert cls.ws is not None projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if (os.path.normcase(projectFile) != os.path.normcase( QgsProject.instance().fileName())): iface.addProject(projectFile)
def setUpClass(cls): # setup auth configuration utils.initAuthManager() utils.populatePKITestCerts() # do workspace population super(PkiDeleteTests, cls).setUpClass() cls.ws = cls.cat.get_workspace(utils.WORKSPACE) assert cls.ws is not None # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase( QgsProject.instance().fileName()): iface.addProject(projectFile) # set flags to instruct GUI interaction cls.confirmDelete = pluginSetting("ConfirmDelete") setPluginSetting("ConfirmDelete", False)
def setUpClass(cls): # setup auth configuration os.environ['QGIS_AUTH_DB_DIR_PATH'] = AUTH_TESTDATA cls.authm = QgsAuthManager.instance() msg = 'Failed to verify master password in auth db' assert cls.authm.setMasterPassword(AUTHDB_MASTERPWD, True), msg # do workspace popuplation super(PkiDeleteTests, cls).setUpClass() cls.ws = cls.cat.get_workspace(WORKSPACE) assert cls.ws is not None # load project projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") if os.path.normcase(projectFile) != os.path.normcase(QgsProject.instance().fileName()): iface.addProject(projectFile) # set flags to instruct GUI interaction cls.confirmDelete = QSettings().value("/GeoServer/Settings/General/ConfirmDelete", True, bool) QSettings().setValue("/GeoServer/Settings/General/ConfirmDelete", False)
def setUpClass(cls): cls.explorer = GeoServerExplorer() # Disable cache cls.cache_time = QSettings().value(SETTINGS_CACHE_TIME) QSettings().setValue(SETTINGS_CACHE_TIME, 1) # check if context is a PKI auth context if hasattr(cls, 'authm') and cls.authm: cls.catWrapper = utils.getGeoServerCatalog(authcfgid=AUTHCFGID, authtype=AUTHTYPE) else: cls.catWrapper = utils.getGeoServerCatalog() cls.cat = cls.catWrapper.catalog utils.populateCatalog(cls.cat) cls.catalogItem = GsCatalogItem(cls.cat, "catalog") cls.explorer.explorerTree.gsItem.addChild(cls.catalogItem) cls.catalogItem.populate() cls.tree = cls.explorer.tree # @TODO - make tests pass using importer cls.useRestApi = QSettings().setValue("/GeoServer/Settings/GeoServer/UseRestApi", True) projectFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "test.qgs") iface.addProject(projectFile)
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") if QGis.QGIS_VERSION_INT < 29900: layer.setRendererV2(renderer) else: layer.setRenderer(renderer) newProjectFile = tempFilename("qgs") proj = QgsProject.instance() proj.write(QFileInfo(newProjectFile)) iface.newProject() iface.addProject(newProjectFile) layer = _layerFromName("2525") if QGis.QGIS_VERSION_INT < 29900: layerRenderer = layer.rendererV2() else: layerRenderer = layer.renderer() self.assertEquals("MilStd2525Renderer", layerRenderer.type())
def openProject(projectFile): if projectFile != QgsProject.instance().fileName(): iface.addProject(projectFile)
def _reload_project(self): """ This will forcefully reload the QGIS project because the project (or its data) may have changed """ qgis_files = find_qgis_files(self.path) if QgsProject.instance().fileName() in qgis_files: iface.addProject(QgsProject.instance().fileName())
def loadTestProject(name): projectFile = os.path.join(os.path.dirname(__file__), "data", name + ".qgs") iface.addProject(projectFile)
def loadTestProject(name = "base"): projectFile = os.path.join(os.path.dirname(__file__), "data", name + ".qgs") currentProjectFile = QgsProject.instance().fileName() if os.path.normpath(currentProjectFile) != os.path.normpath(projectFile): iface.addProject(projectFile)
def loadTestProject(name="base"): projectFile = os.path.join(os.path.dirname(__file__), "data", name + ".qgs") currentProjectFile = QgsProject.instance().fileName() if os.path.normpath(currentProjectFile) != os.path.normpath(projectFile): iface.addProject(projectFile)
def _openProject(): projfile = os.path.join(os.path.dirname(__file__), "data", "project.qgs") iface.addProject(projfile)