How to use _check_links method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

test_qgsserver_request.py

Source:test_qgsserver_request.py Github

copy

Full Screen

...116 'SERVER_NAME': 'somesite.com',117 })118 def test_fcgiRequestPOST(self):119 """Test various combinations of FCGI POST parameters with rewritten urls"""120 def _check_links(params, method='GET'):121 data = urlencode(params)122 if method == 'GET':123 env = {124 'SERVER_NAME': 'www.myserver.com',125 'REQUEST_URI': '/aproject/',126 'QUERY_STRING': data,127 'REQUEST_METHOD': 'GET',128 }129 else:130 env = {131 'SERVER_NAME': 'www.myserver.com',132 'REQUEST_URI': '/aproject/',133 'REQUEST_BODY': data,134 'CONTENT_LENGTH': str(len(data)),135 'REQUEST_METHOD': 'POST',136 }137 self._set_env(env)138 request = QgsFcgiServerRequest()139 response = QgsBufferServerResponse()140 self.server.handleRequest(request, response)141 self.assertFalse(b'ServiceExceptionReport' in response.body())142 if method == 'POST':143 self.assertEqual(request.data(), data.encode('utf8'))144 else:145 original_url = request.originalUrl().toString()146 self.assertTrue(original_url.startswith('http://www.myserver.com/aproject/'))147 self.assertEqual(original_url.find(urlencode({'MAP': params['map']})), -1)148 exp = re.compile(r'href="([^"]+)"', re.DOTALL | re.MULTILINE)149 elems = exp.findall(bytes(response.body()).decode('utf8'))150 self.assertTrue(len(elems) > 0)151 for href in elems:152 self.assertTrue(href.startswith('http://www.myserver.com/aproject/'))153 self.assertEqual(href.find(urlencode({'MAP': params['map']})), -1)154 # Test post request handler155 params = {156 'map': os.path.join(self.testdata_path, 'test_project_wfs.qgs'),157 'REQUEST': 'GetCapabilities',158 'SERVICE': 'WFS',159 }160 _check_links(params)161 _check_links(params, 'POST')162 params['SERVICE'] = 'WMS'163 _check_links(params)164 _check_links(params, 'POST')165 params['SERVICE'] = 'WCS'166 _check_links(params)167 _check_links(params, 'POST')168 params['SERVICE'] = 'WMTS'169 _check_links(params)170 _check_links(params, 'POST')171 def test_add_parameters(self):172 request = QgsServerRequest()173 request.setParameter('FOOBAR', 'foobar')174 self.assertEqual(request.parameter('FOOBAR'), 'foobar')175 self.assertEqual(request.parameter('UNKNOWN'), '')176if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful