def testWriteEntry(self): tmpDir = QTemporaryDir() tmpFile = "{}/project.qgs".format(tmpDir.path()) # zip with existing file project = QgsProject() query = 'select * from "sample DH" where "sample DH"."Elev" > 130 and "sample DH"."Elev" < 140' self.assertTrue(project.writeEntry('myscope', 'myentry', query)) self.assertTrue(project.write(tmpFile)) self.assertTrue(project.read(tmpFile)) q, ok = project.readEntry('myscope', 'myentry') self.assertTrue(ok) self.assertEqual(q, query)
def test_proxy_url(self): """ Test if proxy url is set """ uri = ( '/ows/?service=WPS&request=Execute&Identifier=pyqgiswps_test:testcopylayer&Version=1.0.0' '&MAP=france_parts&DATAINPUTS=INPUT=france_parts%3BOUTPUT=france_parts_2' ) proxy_loc = 'http://test.proxy.loc:8080/anyhwere/' headers = {'X-Forwarded-Url': proxy_loc} rv = self.client.get(uri, path='', headers=headers) assert rv.status_code == 200 # Get the status url status_url = rv.xpath( '/wps:ExecuteResponse')[0].attrib['statusLocation'] q = parse_qs(urlparse(status_url).query) assert 'uuid' in q uuid = q['uuid'][0] # Get the status rv = self.client.get(f"/status/{uuid}?SERVICE=WPS", path='', headers=headers) assert rv.status_code == 200 assert rv.headers.get('Content-Type', '').find('application/json') == 0 st = json.loads(rv.get_data())['status'] # Parse the host url status_url = st['status_url'] assert status_url.startswith(proxy_loc) # Get the project project_path = self.workdir / uuid / 'pyqgiswps_test_testcopylayer.qgs' assert project_path.is_file() project = QgsProject() project.read(str(project_path)) value, ok = project.readEntry('WMSUrl', '/', '') assert ok assert value.startswith(proxy_loc)