Example #1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : do_mysql.py
# @Author: LILIANG
# @Date  : 2019/5/28
# @Desc  :  test

import pymysql
from Api_liliang2.common.config import config
from Api_liliang2.common.logger import my_logger

logger = my_logger(__name__)


class DoMysql:
    """
    完成mysql数据库的交互
    """
    def __init__(self):
        """
        因为数据库,每次连接才能操作,所以直接将连接数据库的方法修改为初始化方法
        """
        try:
            logger.info("读取配置文件中的mysql")
            host = config.get('mysql', 'host')
            user = config.get('mysql', 'user')
            password = config.get('mysql', 'password')
            port = int(config.get('mysql', 'port'))

            # 创建连接
            logger.info("创建连接")
Example #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : http_requests.py
# @Author: LILIANG
# @Date  : 2019/5/23
# @Desc  :  test

import requests
from Api_liliang2.common import logger
from Api_liliang2.common.config import config  #这里是直接导入的config的对象,需要明白不然会报错

logger = logger.my_logger(__name__)
"""
   独立session,cookies需要自己传递
   使用这类的reuquests方法去完成不同的HTTP请求,并返回相应结果
"""


class HttpRequests:
    def requests(self, method, url, data=None, json=None, cookies=None):
        if method.upper() == 'GET':
            resp = requests.get(url, params=data, cookies=cookies)
        elif method.upper() == 'POST':
            if json is None:
                resp = requests.post(url, json=json, cookies=cookies)
            else:
                resp = requests.post(url, data=data, cookies=cookies)
        else:
            resp = None
            print('un-support this method')
        return resp
Example #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : do_excel.py
# @Author: LILIANG
# @Date  : 2019/5/23
# @Desc  :  test

import openpyxl
from Api_liliang2.common import logger
logger = logger.my_logger(__name__)


class Case:
    def __init__(self):
        self.case_id = None
        self.title = None
        self.url = None
        self.data = None
        self.method = None
        self.expected = None
        self.actual = None
        self.result = None
        self.sql = None


class DoExcel:
    def __init__(self, filename, sheetname):
        try:
            self.filename = filename
            self.sheetname = sheetname
            logger.info("加载excel文件")