def test001_login_success(self): app.init_logger() reponse = self.login_token.get_login("13800000002","123456") logging.info("登录结果为:{}".format(reponse.json())) token = "Bearer " + reponse.json().get("data") logging.info("获取的令牌为:{}".format(token)) headers = {"Content-Type":"application/json","Authorization":token} reponse1 = requests.get("http://182.92.81.159/api/company/department",headers=headers) logging.info("获取的部门信息为:{}".format(reponse1.json().get("data").get("depts"))) #添加部门 reponse2 = requests.post("http://182.92.81.159/api/company/department", json={"name":"乔巴","code":"9527"},headers=headers,) logging.info("添加的结果为:{}".format(reponse2.json().get("data"))) assert_conmm_utils(self,reponse2,200,True,10000,"操作成功!") # # #查询部门 # reponse3 = requests.get() # def obtion_department_info(self): # pass # def test002_add_department(self): # pass # def test003_index_department(self): # pass # def test004_delete_department(self): # pass
def test01_login_emp_case(self): app.init_logger() reponse = self.login_api.login_auto("13800000002","123456") logging.info(reponse.json()) token = "Bearer " + reponse.json().get("data") logging.info("id:{}".format(token)) #设置请求头 headers = {"Content-Type":"application/json","Authorization":token} app.HEADERS = headers
import logging import app if __name__ == '__main__': app.init_logger() logging.info("你在干嘛呢")
# 初始化日志配置的代码,应该放在api.__init__.py中 # 为什么呢? # 因为,我们后续所有的接口测试操作,都会通过script脚本运行 # 而script脚本会调用api中封装的接口 # 每次调用api的接口时,都会先运行api模块下面的__init__.py文件 # 从而利用这个机制自动地对日志进行初始化操作 # 初始化后,只要是在调用API后的代码,都能够使用logging打印日志 # 导包,导入app模块和日志模块 import logging # # 初始化日志 # app.init_logger() # 测试 from app import init_logger init_logger()
def markdown2html(md_content): config = { 'codehilite': { 'use_pygments': False, 'css_class': 'prettyprint code', } } return markdown.markdown(md_content, extensions=["codehilite"], extension_configs=config) app = create_app(__name__) init_logger(app) @app.route('/') def index(): return render_template('base.html', md_list=bucket_object_map.keys()) @app.route('/md/<md_name>') def md(md_name): url = get_md_url(md_name) return render_template('md.html', content=markdown2html(get_text(url))) if __name__ == '__main__': app.run(debug=True)
def test001_login_is_success(self, case_name, mobile, password, http_code, success, code, message): app.init_logger() reponse = self.login_api.login_auto(mobile, password) logging.info("登陆成功的结果为:{}".format(reponse.json())) assert_conmm_utils(self, reponse, http_code, success, code, message)