Best Python code snippet using yandex-tank
AmapUtil.py
Source: AmapUtil.py
...173 param['key'] = AMAP_KEY174 param['radius'] = 1000175 param['output'] = 'json'176 return param177 def __cut_name(self, name):178 ' è°æ´å°åå称为çæ ¼å¼ '179 if name.find(u"è¡é") > 0:180 name = name.split(u"è¡é")[1]181 elif name.find(u"é") > 0:182 name = name.split(u"é")[1]183 elif name.find(u"乡") > 0:184 name = name.split(u"乡")[1]185 elif name.find(u"åº") > 0:186 name = name.split(u"åº")[1]187 return name188 @classmethod189 def getRoads(cls, point):190 pos = str(point.longitude) + ',' + str(point.latitude)191 param = cls().__mk_args(pos)192 param['extensions'] = "all"193 try:194 data = requests.get("http://restapi.amap.com/v3/geocode/regeo", param).json()195 if data['info'] == "OK":196 regeo = data.get("regeocode", {})197 out = []198 # éè·¯199 for pos in regeo.get("roads", []):200 road = {}201 lng, lat = pos['location'].split(",")202 road['lat'] = lat203 road['lng'] = lng204 road['name'] = pos['name']205 road['distance'] = pos['distance']206 road['direction'] = pos['direction']207 road['type'] = "road"208 out.append(road)209 # ååè·¯å£210 for pos in regeo.get("roadinters", []):211 road = {}212 lng, lat = pos['location'].split(",")213 road['lat'] = lat214 road['lng'] = lng215 road['name'] = pos['first_name']216 road['distance'] = pos['distance']217 road['direction'] = pos['direction']218 road['type'] = "roadinter"219 # out.append(road)220 return out221 else:222 return []223 except Exception, e:224 print e225 return []226 @classmethod227 def getName(cls, point):228 obj = cls()229 pos = str(point.longitude) + ',' + str(point.latitude)230 param = obj.__mk_args(pos)231 try:232 data = requests.get("http://restapi.amap.com/v3/geocode/regeo", param).json()233 if data['info'] == "OK":234 regeo = data.get("regeocode", {})235 return obj.__cut_name(regeo.get('formatted_address', ""))236 else:237 return ""238 except Exception, e:239 print e240 return ""241 @classmethod242 def getNameBatch(cls, points):243 ' 20个ä¸æ¹æ¬¡è°ç¨é«å¾·regeoæ¥å£,è¿åå°å '244 obj = cls()245 out = []246 for chunk in chunks(points, 20):247 pos = '|'.join([str(x.longitude) + ',' + str(x.latitude) for x in chunk])248 param = obj.__mk_args(pos)249 param['batch'] = "true"250 try:251 data = requests.get("http://restapi.amap.com/v3/geocode/regeo", param).json()252 if data['info'] == "OK":253 regeos = data.get("regeocodes", {})254 for pos in regeos:255 out.append(obj.__cut_name(pos.get('formatted_address', "")))256 except Exception, e:257 print e258 return out259class AmapBatch():260 def __batch_by_amap(self, urls):261 if not isinstance(urls, list):262 raise ValueError("input urls must be list")263 if len(urls) > 20:264 raise ValueError("at most 20 url one time")265 param = dict()266 param['ops'] = map(lambda url: dict(url=url), urls)267 url = "http://restapi.amap.com/v3/batch?key=" + AMAP_KEY268 headers = {'Content-type': 'application/json'}269 return requests.post(url, data=json.dumps(param), headers=headers).json()...
Check out the latest blogs from LambdaTest on this topic:
The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.
Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.
Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.
“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!