def api_notice_published_get(self, url, page_size, page_num, keywords=None): session = GetSession().get_session() params = {'action': 'listbypage', 'pagesize': page_size, 'pagenum': page_num, 'keywords': keywords, 'withoutcontent': 'true'} return session.get(url, params=params)
def api_list_get(self, url, page_size, page_num, keywords=None): session = GetSession().get_session() params = { 'action': 'listbypage', 'pagesize': page_size, 'pagenum': page_num, 'keywords': keywords } return session.get(url, params=params)
def api_fb_set(self, url): headers = {'Content-Type': 'application/json'} data = { "action": "set", "name": "homepage", "value": "{\"news\":[5],\"notice\":[1],\"paper\":[5]}" } session = GetSession().get_session() return session.post(url, json=data, headers=headers)
def api_upload(self, url): with open(BASE_PATH + os.sep + 'data' + os.sep + '我的头像.jpg', 'rb') as f: headers = { 'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" } file = {'upload1': f} session = GetSession().get_session() return session.post(url, files=file)
def api_add_notice_post(self, url, title, content): headers = {'Content-Type': 'application/json'} data = { "action": "addone", "data": { "title": title, "content": content } } session = GetSession().get_session() return session.post(url, json=data, headers=headers)
def api_modify_account(self, url, id, realname): headers = {'Content-Type': 'application/json'} data = { "action": "modifyone", "id": id, "newdata": { "realname": realname, } } session = GetSession().get_session() return session.put(url, json=data, headers=headers)
def api_set_info(self, name, url): headers = {'Content-Type': 'application/json'} params = {"action": "getmyprofile"} session = GetSession().get_session() data = { "action": "setmyprofile", "newdata": { "realname": name, "password": "******" } } return session.post(url, json=data, params=params, headers=headers)
def teardown_class(cls): GetSession().get_session().post( api.fb_url, json={ "action": "set", "name": "homepage", "value": "{\"news\":[5,7,6,3,4],\"notice\":[1,3,5,2]" ",\"paper\":[5,9,10,4,8]}" }, headers={'Content-Type': 'application/json'}) ApiLogout().Api_logout_post(url=api.logout_url) GetSession().clear_session()
def api_add_account_post(self, url, realname, username, password, number, desc, type): headers = {'Content-Type': 'application/json'} data = { "action": "addone", "data": { "realname": realname, "username": username, "password": password, "studentno": number, "desc": desc, "usertype": type } } session = GetSession().get_session() return session.post(url, json=data, headers=headers)
def test07_list_all(self): headers = {'Content-Type': 'application/json'} data = {"action": "signin", "username": '******', "password": '******'} GetSession.get_session().post(api.login_url, json=data, headers=headers) params = { 'action': 'listbypage', 'pagesize': 10, 'pagenum': 1, 'keywords': '' } re = GetSession.get_session().get(api.work_flow, params=params) assert re.status_code == 200 assert re.json()['ret'] == 0 assert re.json()['total'] == 4
def setup_class(cls): run_sql('delete from cimp_wf_design where creator_id = 12 ') run_sql( 'delete from cimp_wf_design_step where operator_id = 12 or operator_id = 13' ) headers = {'Content-Type': 'application/json'} data = {"action": "signin", "username": '******', "password": '******'} data2 = { "action": "signin", "username": '******', "password": '******' } GetSession.get_session().post(api.login_url, json=data, headers=headers) GetSession.get_session2().post(api.login_url, json=data2, headers=headers)
def test09_check_step(self): result = ( '{"ret": 0, "data": [{"name": "毕业设计标题", "type": "text", "value": ' '"阿水电费水电费水电费ds"}, {"name": "主题描述", "type": "textarea", "value": ' '"阿萨德但是但是是的是第三方第三方是否但是"}]}') params = {'action': 'getstepactiondata', 'step_id': 12} re = GetSession.get_session().get(api.work_flow, params=params) assert re.status_code == 200 assert re.text == result
def teardown_class(cls): headers = {'Content-Type': 'application/json'} data = {"action": "signout"} GetSession.get_session().post(api.logout_url, json=data, headers=headers) GetSession.get_session2().post(api.login_url, json=data, headers=headers) GetSession().clear_session() GetSession().clear_session2()
def test04_approve(self): headers = {'Content-Type': 'application/json'} data = { "action": "stepaction", "key": "approve_topic", "wf_id": self.wk_id, "submitdata": [{ "name": "备注", "type": "richtext", "value": "222222222222222222222222222222" }] } re2 = GetSession.get_session2().post(url=api.work_flow, json=data, headers=headers) assert re2.json()['ret'] == 0
def test05_submit(self): headers = {'Content-Type': 'application/json'} data = { "action": "stepaction", "key": "submit_design", "wf_id": self.wk_id, "submitdata": [{ "name": "毕业设计内容", "type": "richtext", "value": "898494949849494984949444498498449" }] } re1 = GetSession.get_session().post(url=api.work_flow, json=data, headers=headers) assert re1.json()['ret'] == 0
def test02_reject(self): headers = {'Content-Type': 'application/json'} data = { "action": "stepaction", "key": "reject_topic", "wf_id": self.wk_id, "submitdata": [{ "name": "驳回原因", "type": "textarea", "value": "asdfsadfasfasfdf" }] } re2 = GetSession.get_session2().post(url=api.work_flow, json=data, headers=headers) assert re2.json()['ret'] == 0
def test03_modify(self): headers = {'Content-Type': 'application/json'} data = { "action": "stepaction", "key": "modify_topic", "wf_id": self.wk_id, "submitdata": [{ "name": "毕业设计标题", "type": "text", "value": "test01的毕业设计2" }, { "name": "主题描述", "type": "richtext", "value": "这是我的毕业设计11111113" }] } re1 = GetSession.get_session().post(url=api.work_flow, json=data, headers=headers) assert re1.json()['ret'] == 0
def test06_score(self): headers = {'Content-Type': 'application/json'} data = { "action": "stepaction", "key": "score_design", "wf_id": self.wk_id, "submitdata": [{ "name": "得分", "type": "int", "value": 100 }, { "name": "备注", "type": "richtext", "value": "8949498191919191981981" }] } re2 = GetSession.get_session2().post(url=api.work_flow, json=data, headers=headers) assert re2.json()['ret'] == 0
def api_click(self, url): headers = {'Content-Type': 'application/json'} data = {"action": "thumbuporcancel", "paperid": 5} session = GetSession().get_session() return session.post(url, json=data, headers=headers)
def api_delete_account(self, url, id): headers = {'Content-Type': 'application/json'} data = {"action": "deleteone", "id": id} session = GetSession().get_session() return session.delete(url, json=data, headers=headers)
def teardown_class(cls): GetSession.clear_session()
def api_info(self, url): params = {"action": "getmyprofile"} session = GetSession().get_session() return session.get(url, params=params)
def Api_logout_post(self, url): headers = {'Content-Type': 'application/json'} data = {"action": "signout"} session = GetSession.get_session() return session.post(url, json=data, headers=headers)
def api_ban_notice(self, url, id): headers = {'Content-Type': 'application/json'} data = {"action": "banone", "id": id} session = GetSession().get_session() return session.put(url, json=data, headers=headers)
def api_fb_get(self, url): params = {"action": "gethomepagebyconfig"} session = GetSession().get_session() return session.get(url, params=params)
def api_notice_one(self, url, id): session = GetSession().get_session() params = {'action': 'getone', 'id': id} return session.get(url, params=params)
def teardown_class(cls): ApiSetInfo().api_set_info(name='学员1', url=api.info_url) ApiLogout().Api_logout_post(url=api.logout_url) GetSession().clear_session()
def teardown_class(cls): ApiLogout().Api_logout_post(url=api.logout_url) GetSession().clear_session()
def test08_get_one(self): headers = {'Content-Type': 'application/json'} params = {'action': 'getone', 'wf_id': self.wk_id, 'keywords': ''} re = GetSession.get_session().get(api.work_flow, params=params) assert re.status_code == 200 assert re.json()['ret'] == 0