Best Python code snippet using tempest_python
test_wework.py
Source:test_wework.py
...55 }56 r = requests.post(f"https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token={token}", json=request_body,57 verify=False)58 return r.json()59 def test_get_user(self, token, userid):60 """61 è·åæåä¿¡æ¯62 :return:63 """64 r = requests.get(f"https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={token}&userid={userid}",65 verify=False)66 # print(r.json())67 return r.json()68 def test_update_user(self, token, userid, name="æ¯å"):69 """70 æ´æ°æåä¿¡æ¯71 :return:72 """73 requests_body = {74 "userid": userid,75 "name": name76 }77 r = requests.post(f"https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token={token}", json=requests_body,78 verify=False)79 # print(r.json())80 return r.json()81 def test_delete_user(self, token, userid):82 """83 å é¤æåä¿¡æ¯84 :return:85 """86 r = requests.get(f"https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token={token}&userid={userid}",87 verify=False)88 return r.json()89 @pytest.mark.parametrize("userid, name, mobile", test_data())90 def test_wework(self, token, userid, name, mobile):91 """92 æ´ä½æµè¯93 :return:94 """95 try:96 assert "created" == self.test_create_user(token, userid, mobile)["errmsg"]97 except AssertionError as e:98 if "mobile existed" in e.__str__():99 re_userid = re.findll(":(.*)'$", e.__str__())[0] # print(e)=e.__str__100 self.test_delete_user(token, re_userid)101 assert "created" == self.test_create_user(token, userid, mobile)["errmsg"]102 assert name == self.test_get_user(token, userid)["name"]103 assert "updated" == self.test_update_user(token, userid, name="æ¯å5555")["errmsg"]104 assert "æ¯å5555" == self.test_get_user(token, userid)["name"]105 assert "deleted" == self.test_delete_user(token, userid)["errmsg"]...
TestTwitterDataAccessObject.py
Source:TestTwitterDataAccessObject.py
...4# DEFAULT_USER_ID = 2167519045# DEFAULT_USER_ID = 8132866DEFAULT_NAME = '@JaredWads'7DEFAULT_KEYWORD = '#python'8def test_get_user(user_id=DEFAULT_USER_ID):9 dao = TwitterDataAccessObject()10 start_time = time.time()11 user = dao.get_user(user_id)12 print("--- test_get_user took {0} seconds ---".format(time.time() - start_time))13 print "Retrieved User {0}".format(user['screen_name'])14def test_get_user_statuses(user_id=DEFAULT_USER_ID):15 dao = TwitterDataAccessObject()16 start_time = time.time()17 statuses = dao.get_user_statuses(user_id)18 print("--- test_get_user took {0} seconds ---".format(time.time() - start_time))19 print "Retrieved {0} statuses".format(len(statuses))20def test_get_following(user_id=DEFAULT_USER_ID):21 dao = TwitterDataAccessObject()22 start_time = time.time()23 following = dao.get_following_ids_by_user_id(user_id)24 print("--- test_get_user took {0} seconds ---".format(time.time() - start_time))25 print "Retrieved {0} following".format(len(following))26def test_get_followers(user_id=DEFAULT_USER_ID):27 dao = TwitterDataAccessObject()28 start_time = time.time()29 followers = dao.get_followers_ids_by_user_id(user_id)30 print("--- test_get_user took {0} seconds ---".format(time.time() - start_time))31 print "Retrieved {0} following".format(len(followers))32def main():33 test_get_user()34 test_get_user_statuses()35 test_get_following()36 test_get_followers()...
test_users.py
Source:test_users.py
2from test_utils.test_utils import AuthUser3def test_get_users():4 url = 'http://localhost:5000/api/users'5 return test_url(url, method="GET", auth=True)6def test_get_user(userId: str):7 url = 'http://localhost:5000/api/users/%s' % userId8 return test_url(url, method="GET", auth=True)9if __name__ == '__main__':10 users = test_get_users()11 user = test_get_user(userId="xiangling00")...
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!!