How to use test_get_access_token method in tempest

Best Python code snippet using tempest_python

test_api_demo.py

Source:test_api_demo.py Github

copy

Full Screen

1import requests2import json3def test_get_access_token():4 url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wwf793a42682053e6e&corpsecret=qdXH8QRbJhkgXu3jlP0S531suzE6cZ8LTwOQkJ4d1F8'5 token_response = requests.get(url)6 token = json.loads(token_response.text)7 return token['access_token']8def test_get_member_list():9 url = f'https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={test_get_access_token()}&userid=zhangsan'10 get_member_response = requests.get(url)11 get_member = json.loads(get_member_response.text)12 assert get_member['userid'] == 'zhangsan'13def test_add_member():14 url = f'https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token={test_get_access_token()}'15 data = {16 "userid": "TomBlank",17 "name": "TomBlank",18 "department": "1",19 "mobile": "13567676666",20 }21 add_member_response = requests.post(url=url, json=data)22 add_member = json.loads(add_member_response.text)23 assert 'created' in add_member['errmsg']24def test_delete_member():25 url = f'https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token={test_get_access_token()}&userid=TomBlank'26 delete_member_response = requests.get(url)27 delete_member = json.loads(delete_member_response.text)28 assert delete_member['errmsg'] == 'deleted'29def test_update_member():30 url = f'https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token={test_get_access_token()}'31 data = {32 "userid": 'zhangsan',33 "name": '张三',34 "mobile": '13800088000',35 }36 update_member_response = requests.post(url=url, json=data)37 update_member = json.loads(update_member_response.text)...

Full Screen

Full Screen

tests_pre_start.py

Source:tests_pre_start.py Github

copy

Full Screen

...16 try:17 # Try to create session to check if DB is awake18 db_session.execute("SELECT 1")19 # Wait for API to be awake, run one simple tests to authenticate20 test_get_access_token()21 except Exception as e:22 logger.error(e)23 raise e24def main():25 logger.info("Initializing service")26 init()27 logger.info("Service finished initializing")28if __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 tempest 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