Best Python code snippet using yandex-tank
hook.py
Source:hook.py
...39 while True:40 local_repo = payload = None41 try:42 local_repo, payload = queue.get()43 _do_handle(local_repo, payload)44 except:45 traceback.print_exc()46 print >> sys.stderr, 'payload:'47 pprint.pprint(payload, sys.stderr)48 print >> sys.stderr49queue = Queue.Queue()50thread.start_new_thread(_handle_thread, ())51def handle(payload, test=True):52 path = payload['repository']['absolute_url']53 owner = payload['repository']['owner']54 local_repo = app.config['LOCAL_REPOS'].join(path)55 remote_repo = app.config['REMOTE_BASE'] + path56 if not check_for_local_repo(local_repo, remote_repo, owner):57 print >> sys.stderr, 'Ignoring unknown repo', path58 return59 if test:60 _do_handle(local_repo, payload, test)61 else:62 queue.put((local_repo, payload))63def _do_handle(local_repo, payload, test=False):64 scm.hg('pull', '-R', local_repo)65 for commit in get_commits(payload):66 for handler in HANDLERS:...
test_pandora_plugin.py
Source:test_pandora_plugin.py
...4from threading import Thread5from yandextank.plugins.Pandora import Plugin6# https://raw.githubusercontent.com/yandex/yandex-tank/develop/README.md7class RequestHandler(SimpleHTTPRequestHandler):8 def _do_handle(self):9 content = '{"test": "ammo"}'.encode('utf-8')10 self.send_response(200)11 self.send_header('Content-Type', 'application/json')12 self.send_header('Content-Length', len(content))13 self.end_headers()14 self.wfile.write(content)15 def do_GET(self):16 self._do_handle()17 def do_HEAD(self):18 self._do_handle()19SERVER = HTTPServer(('localhost', 1234), RequestHandler)20THREAD = Thread(target=SERVER.serve_forever, name="StatServer")21def setup_module(module):22 THREAD.start()23@pytest.mark.parametrize('cfg, expected', [24 (25 {'pools': [26 {27 'ammo': {'uri-headers': '[User-Agent: Wget/1.13.4 (linux-gnu)] [Host: foo.ru] [Accept-Encoding: gzip,deflate,sdch]',28 'type': 'uri',29 'file': 'http://localhost:1234/ammo'30 }31 }]},32 {'pools': [...
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!!