Best Python code snippet using responses
test.py
Source:test.py
...18def test_delete(url):19 print(requests.delete(BASE_URL + url).json())202122def test_put(url, json):23 print(requests.put(BASE_URL + url, json=json).json())242526# test_get('jobs')27# test_get('jobs/1')28# test_get('jobs/10000000000')29# test_get('jobs/nekstas')3031# # ÐоÑÑекÑнÑй запÑÐ¾Ñ 132# test_post('jobs', {33# 'collaborators': '1',34# 'end_date': datetime.datetime.now().isoformat(),35# 'is_finished': False,36# 'job': 'job_k',37# 'start_date': datetime.datetime.now().isoformat(),38# 'team_leader': 1,39# 'work_size': 1640# })41#42# # ÐоÑÑекÑнÑй запÑÐ¾Ñ 243# test_post('jobs', {44# 'collaborators': '1',45# 'end_date': None,46# 'is_finished': True,47# 'job': 'job_{k+1}',48# 'start_date': None,49# 'team_leader': 1,50# 'work_size': 2451# })52#53# # ÐоÑÑекÑнÑй запÑÐ¾Ñ 354# test_post('jobs', {55# 'collaborators': '1',56# 'end_date': None,57# 'is_finished': False,58# 'job': 'job_{k+2}',59# 'start_date': None,60# 'team_leader': 1,61# 'work_size': 1062# })63#64# # ÐекоÑÑекÑнÑй запÑÐ¾Ñ 165# # ÐообÑе ниÑего не пеÑедано (Empty request)66# test_post('jobs', {})67#68# # ÐекоÑÑекÑнÑй запÑÐ¾Ñ 269# # Ðе пеÑедан паÑамеÑÑ collaborators (Bad request)70# test_post('jobs', {71# 'end_date': None,72# 'is_finished': False,73# 'job': 'job1',74# 'start_date': None,75# 'team_leader': 1,76# 'work_size': 1677# })78#79# # ÐекоÑÑекÑнÑй запÑÐ¾Ñ 380# # end_date не None и не в ноÑмалÑном ÑоÑмаÑе (инÑоÑмаÑÐ¸Ñ ÐµÑÑÑ, но она непÑавилÑного Ñипа) (Invalid data)81# test_post('jobs', {82# 'collaborators': '1',83# 'end_date': '1234',84# 'is_finished': False,85# 'job': 'job1',86# 'start_date': None,87# 'team_leader': 1,88# 'work_size': 1689# })90#91# test_get('jobs')9293# # ÐоÑÑекÑнÑй, еÑли еÑÑÑ ÑабоÑа Ñ id=194# test_delete('jobs/1')95#96# # ÐекоÑÑекÑнÑй, еÑли Ð½ÐµÑ ÑабоÑÑ Ñ id=1000000000097# test_delete('jobs/10000000000')98#99# # ÐекоÑÑекÑнÑй, не ÑиÑло100# test_delete('jobs/nekstas')101#102# test_get('jobs')103104# # ÐоÑÑекÑнÑй 1, еÑли еÑÑÑ ÑабоÑа Ñ id=2105# test_put('jobs/2', {106# 'work_size': 10107# })108#109# # ÐоÑÑекÑнÑй 2, еÑли еÑÑÑ ÑабоÑа Ñ id=3110# test_put('jobs/3', {111# 'work_size': 14,112# 'end_date': datetime.datetime.now().isoformat(),113# 'job': 'job3.333'114# })115#116# # ÐекоÑÑекÑнÑй 1, еÑли Ð½ÐµÑ ÑабоÑÑ Ñ id=10000000000 (Not Found)117# test_put('jobs/10000000000', {118# 'work_size': 14,119# 'end_date': datetime.datetime.now().isoformat(),120# 'job': 'job3.333'121# })122#123# # ÐекоÑÑекÑнÑй 2, Ð½ÐµÑ Ð´Ð°Ð½Ð½ÑÑ
Ð´Ð»Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ (Empty request)124# test_put('jobs/5', {})125#126# # ÐекоÑÑекÑнÑй 3, еÑли еÑÑÑ ÑабоÑа c id=1, даÑа в невеÑном ÑоÑмаÑе (Invalid date)127# test_put('jobs/5', {128# 'end_date': '1234'
...
s3tester.py
Source:s3tester.py
...13# handler.setFormatter(formatter)14# logger.addHandler(handler)15# logger.setLevel(logging.INFO)16#17#def test_put(local_file):18# s3.put(local_file)19# 20#21#def test_get(filekey):22# s3.get(filekey) 23#24#def test_get_url(filekey):25# return s3.get_url(filekey) 26# 27#if __name__ == '__main__':28# pass29## init_logging('/var/log/s3.log')30## test_put('/srv/upload/snapshot/jintao/11.jpg')31## test_put('/srv/upload/snapshot/jintao/22.jpg')32## test_put('/srv/upload/snapshot/jintao/jintao.jpg')33## test_put('/srv/upload/rendition/jintao/jintao.mp4')34## test_put('/srv/upload/uploaded-video/jintao/jintao')35## test_put('/srv/upload/uploaded-asset/jintao/jintao.ts')36#37# test_get('snapshot/jintao/11.jpg')38# test_get('snapshot/jintao/22.jpg') 39# test_get('snapshot/jintao/jintao.jpg')40# test_get('rendition/jintao/jintao.mp4')41# test_get('uploaded-video/jintao/jintao')42# test_get('uploaded-asset/jintao/jintao.ts') 43## print test_get_url('snapshot/jintao/11.jpg')44## print test_get_url('snapshot/jintao/22.jpg') 45## print test_get_url('snapshot/jintao/jintao.jpg')46## print test_get_url('rendition/jintao/jintao.mp4') 47## print test_get_url('uploaded-video/jintao/jintao') ...
junior.py
Source:junior.py
...17class TestClass:18 def __init__(self, total: int):19 self.total = total20 self.data = ArrayInterface()21 def test_put(self):22 start = time.time()23 for item in range(self.total):24 self.data.put(item)25 return f"{self.total}: {time.time() - start}"26t = TestClass(10).test_put()27t1 = TestClass(100).test_put()28t2 = TestClass(1000).test_put()29t3 = TestClass(10000).test_put()30t4 = TestClass(100000).test_put()31t5 = TestClass(1000000).test_put()...
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!!