def create(self, dict=None, data=None): return requests.post("https://qyapi.weixin.qq.com/cgi-bin/user/create", params={ "access_token": Weixin.get_token() }, json=dict, data=data).json()
def delete_department(self): return requests.get( "https://qyapi.weixin.qq.com/cgi-bin/department/delete", params={ "access_token": Weixin.get_token(), "id": 281 }).json()
def token(): return Weixin.get_token_new() # pytest.fixture标识,定义在函数前面. # 在你编写测试函数的时候,你可以将此函数名称做为传入参数,pytest将会以依赖注入方式,将该函数的返回值作为测试函数的传入参数。 # 我们可以把fixture看做是资源,在你的测试用例执行之前需要去配置这些资源,执行完后需要去释放资源。适合于那些许多测试用例都只需要执行一次操作。
def create(self, data): return requests.post( "https://qyapi.weixin.qq.com/cgi-bin/department/create", params={ "access_token": Weixin.get_token() }, json=data).json()
def create_user(self, dic=None, data=None): r = requests.post('https://qyapi.weixin.qq.com/cgi-bin/user/create', params={ 'access_token': Weixin.get_token() }, json=dic, data=data).json() return r
def list(self, department_id=1, fetch_child=0, **kwargs): return requests.get( "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist", params={ "access_token": Weixin.get_token(), "department_id": department_id, "fetch_child": fetch_child }).json()
def get_list(self, department_id=1, fetch_child=0, **kwargs): params = { 'access_token': Weixin.get_token(), 'department_id': department_id, 'fetch_child': fetch_child } r = requests.get('https://qyapi.weixin.qq.com/cgi-bin/user/simplelist', params=params).json() return r
def test_create_order(self, name): data = { "name": name, "parentid": 1, "order": 1, } r = requests.post('https://qyapi.weixin.qq.com/cgi-bin/department/create', params={'access_token': Weixin.get_token()}, json=data).json() logging.debug(r)
def create(self, dict=None, data=None): return requests.post("https://qyapi.weixin.qq.com/cgi-bin/user/create", params={ "access_token": Weixin.get_token() }, json=dict, data=data, headers={ "content-type": "application/json;charset=UTF-8" }).json()
def test_create_depth(self): parentid = 1 for i in range(5): data = { "name": "广州研发中心分部_" + str(parentid), "parentid": parentid, "order": 1, } r = requests.post('https://qyapi.weixin.qq.com/cgi-bin/department/create', params={'access_token': Weixin.get_token()}, json=data).json() logging.debug(r) parentid = r['id']
def test_create_by_template(self): # print(pystache.render("hello {{name}} {{#has}} world {{value}} {{/has}}", # {"name": "xiaohua", # "has": [ {"value":1},{"value":2},{"value":3} ], # "value":"good"})) uid = "huakai_"+str(int(time.time())) mobile = str(12)+str(time.time()).replace(".", "")[0:9] data = str(Utils.parse("user_create.json", { "name": uid, "title": "产品", "email": mobile + "@qq.com" })) data = data.encode("UTF-8") #r = self.user.create(data) r=requests.post("https://qyapi.weixin.qq.com/cgi-bin/user/create", params={"access_token": Weixin.get_token()}, data=data, headers={"content-type":"application/json;charset=UTF-8"} ).json() logging.debug(r) assert r["errcode"]==0
def test_token(self): logging.info(Weixin.get_token()) assert Weixin.get_token() != ""
def token(): return Weixin.get_token_new()
def setup_class(cls): print('\nsetup_class') Weixin.get_token() print(Weixin._token)
def test_get(self): r = requests.get('https://qyapi.weixin.qq.com/cgi-bin/department/list', params={'access_token': Weixin.get_token()}).json() logging.debug(json.dumps(r, indent=2))
def delete(self): params = {"access_token": Weixin.get_token(), "userid": "tuhi001"} return requests.get("https://qyapi.weixin.qq.com/cgi-bin/user/delete", params=params).json()
def get_department(self): return requests.get( "https://qyapi.weixin.qq.com/cgi-bin/department/list", params={ "access_token": Weixin.get_token() }).json()
def read(self, userid="ruhi001"): params = {"access_token": Weixin.get_token(), "userid": userid} return requests.get("https://qyapi.weixin.qq.com/cgi-bin/user/get", params=params).json()
def test_get_token(self): print(Weixin.get_token()) assert Weixin.get_token() != ""
def token(): print(Weixin.get_token_new()) return Weixin.get_token_new()