from app import db
class Curd(object):
def init(self,modelName):
self.db_model = globals()[modelName]
def read(self,**filters):
'''
:param filters: {key1:value1,key2,value2}
:return:
'''
obj = self.db_model.query.filter_by(**filters).all()
return obj
def create(self, records):
'''
根据db_model向不同的表中插入测试数据
:param modelName:
:param records: [{},{}]
:return:
'''
for record in records:
api_purpose = record['api_purpose']
request_url = record['request_url']
request_method = record['request_method']
request_data_type = record['request_data_type']
request_data = record['request_data']
assert_method = record['assert_method']
check_point = record['check_point']
correlation = record['correlation']
active = record['active']
creater = record['creater']
project = record['project']
case = self.db_model(api_purpose=api_purpose, request_url=request_url,
request_method=request_method,
request_data_type=request_data_type, request_data=request_data,
assert_method=assert_method, check_point=check_point,
correlation=correlation, active=active,
creater=creater, project=project)
db.session.add(case)
db.session.commit()
def update(self, **kwargs):
pass
def delete(self):
pass