等峰也等你

博客园 首页 新随笔 联系 订阅 管理
import requests


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"
posted on 2024-05-08 14:52  等峰也等你  阅读(6)  评论(0编辑  收藏  举报