import requests标签:27,url,微信,self,json,token,L2,res,corp From: https://www.cnblogs.com/csfsz/p/18179757
class TestWework:
def test_get_token(self):
self.corp_id = "ww0500b1708efeb406"
self.corp_secret = "5fas7s3wQzC6k5W11SqZ1dxMcXvC57yKXi_NMVXu4pkBNY"
self.base_url = "https://qyapi.weixi11n.qq.codm/cgi-bin/gettoken"
params = {
"corpid": self.corp_id,
"corpsecret": self.corp_secret
}
res = requests.request("GET", url=self.base_url, params=params)
assert res.status_code == 200
assert res.json()["errmsg"] == "ok"
self.token = res.json()["access_token"]
return self.token
def test_create_department(self):
url = f"https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token={self.test_get_token()}"
res = requests.request("GET", url=url)
assert res.json()["errmsg"] == "created"