Пример #1
0
    def test_infrastructure_add(self, **kwargs):
        try:
            col_num = kwargs.get('row') - 1
            excel_data_1 = GetExcelCase(
                fileName=
                r'E:\Auto-interface\data\infrastructure\infrastructure_case.xlsx',
                sheetName='楼栋房屋新增').get_dict_data[col_num]
            self.log.logger.debug(f'获取的测试数据:{excel_data_1}')
            actual_result = self.infrastructrue_b.infrastructure_add_busniess(
                add_excel_data, **excel_data_1)
            if actual_result:
                self.assertEqual(
                    excel_data_1.get('expected_result'),
                    actual_result[0].get('msg'),
                    msg=f'失败用例:{kwargs.get("case")}\n服务器返回内容:'
                    f'{actual_result[0]}\n响应时间:{actual_result[1]}\n状态码{actual_result[2]}'
                )

            else:
                raise
        except Exception as e:
            self.log.logger.info(e)
            raise e
        else:
            self.log.logger.info(
                f'"{kwargs.get("case")}"用例执行通过,响应时间:{actual_result[1]},状态码{actual_result[2]}'
            )
 def unit_modify_busniess(self, **kwargs):
     get_unit_uuid = GetExcelCase(
         r'E:\Auto-interface\data\unit_management\unit_management_uuid.xlsx',
         '单位管理')
     unit_uuid_data = eval(get_unit_uuid.get_dict_data[0]['uuid'])[0]
     get_infrastructure_uuid = GetExcelCase(
         r'E:\Auto-interface\data\infrastructure\infrastructure_uuid.xlsx',
         '楼栋房屋')
     self.log.logger.debug(f'unit_uuid:{unit_uuid_data}')
     infrastructure_uuid = eval(
         get_infrastructure_uuid.get_dict_data[7]['uuid'])[0]
     self.log.logger.debug(f'in_uuid:{infrastructure_uuid}')
     self.log.logger.debug(type(kwargs['json']))
     kwargs1 = eval(
         str(kwargs).replace(
             eval(kwargs['json'])['infrastructureUuid'],
             infrastructure_uuid))
     kwargs2 = eval(
         str(kwargs1).replace(
             eval(kwargs1['json'])['companyUuid'], unit_uuid_data))
     self.log.logger.debug(f'kwargs{type(kwargs2)}')
     response = self.res.method(**kwargs2)
     if response:
         return response
     else:
         return False
 def setUpClass(cls) -> None:
     cls.log = Logger()
     cls.unit_uuid_file = ReadConf().get_conf('UNITMANAGEMENTUUID').get('unit_management_uuid')
     cls.unit_management_b = UnitManagementBusniess()
     cls.replace_unit_query = ReplaceData(unit_query_data, unit_case_file, '单位管理查找')
     cls.new_infrastructure_uuid_data = GetExcelCase(infrastructure_uuid_file, '楼栋房屋').get_dict_data
     cls.replace_unit_query.replace_data_sheet(cls.new_infrastructure_uuid_data)
     cls.new_unit_query_data = GetExcelCase(unit_case_file, '单位管理查找').get_dict_data
Пример #4
0
 def setUpClass(cls) -> None:
     cls.log = Logger()
     cls.infrastructrue_b = InfrastructureBusniess()
     cls.uuid_data = GetExcelCase(uuid_file, '楼栋房屋').get_dict_data
     cls.replace_infrastructure_delete = ReplaceData(
         delete_excel_data, infrastructure_case_file, '楼栋房屋删除')
     cls.replace_infrastructure_delete.replace_data_sheet(cls.uuid_data)
     cls.new_infrastructure_delete_data = GetExcelCase(
         infrastructure_case_file, '楼栋房屋删除').get_dict_data
 def setUpClass(cls) -> None:
     cls.log = Logger()
     cls.unit_management_b = UnitManagementBusniess()
     cls.replace_unit_delete = ReplaceData(unit_delete_data, unit_case_file,
                                           '单位管理删除')
     cls.replace_unit_delete.replace_data_sheet(unit_uuid_data)
     cls.new_unit_delete_data = GetExcelCase(unit_case_file,
                                             '单位管理查找').get_dict_data
import unittest
import ddt
from tools.get_excel_case import GetExcelCase
from tools.log import Logger
from busniess.UnitMagementBusniess.unit_magement_busniess import UnitManagementBusniess
from tools.replace_data import ReplaceData
from tools.read_conf import ReadConf
import HTMLTestRunner_Chart, time

unit_case_file = ReadConf().get_conf('UNITMANAGEMENT').get('unit_management')
infrastructure_uuid_file = ReadConf().get_conf('INFRASTRUCTUREUUID').get(
    'infrastructure_uuid')
unit_uuid_file = ReadConf().get_conf('UNITMANAGEMENTUUID').get(
    'unit_management_uuid')
# 加载uuid
infrastructure_uuid_data = GetExcelCase(infrastructure_uuid_file,
                                        '楼栋房屋').get_dict_data
unit_uuid_data = GetExcelCase(unit_uuid_file, '单位管理').get_dict_data
# 加载测试数据
unit_add_data = GetExcelCase(unit_case_file, '单位管理新增').get_dict_data
# 替换uuid
replace_unit_add = ReplaceData(unit_add_data, unit_case_file, '单位管理新增')
replace_unit_add.replace_data_sheet(infrastructure_uuid_data)
# 获取最新测试数据
new_unit_add_data = GetExcelCase(unit_case_file, '单位管理新增').get_dict_data


@ddt.ddt
class UnitManangementAdd(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.log = Logger()
@File    : test03_unit_management_modify.py
'''

import unittest
import ddt
from tools.get_excel_case import GetExcelCase
from tools.log import Logger
from busniess.UnitMagementBusniess.unit_magement_busniess import UnitManagementBusniess
from tools.replace_data import ReplaceData
from tools.read_conf import ReadConf
import HTMLTestRunner_Chart, time

unit_case_file = ReadConf().get_conf('UNITMANAGEMENT').get('unit_management')
unit_uuid_file = ReadConf().get_conf('UNITMANAGEMENTUUID').get('unit_management_uuid')
# 加载uuid
unit_uuid_data = GetExcelCase(unit_uuid_file, '单位管理').get_dict_data
# 加载测试数据
unit_modify_data = GetExcelCase(unit_case_file, '单位管理修改').get_dict_data


@ddt.ddt
class UnitManangementModify(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.log = Logger()
        cls.unit_management_b = UnitManagementBusniess()

    def setUp(self) -> None:
        time.sleep(1)

    @ddt.data(*unit_modify_data)
@File    : test04_unit_management_delete.py
'''

import unittest
import ddt
from tools.get_excel_case import GetExcelCase
from tools.log import Logger
from busniess.UnitMagementBusniess.unit_magement_busniess import UnitManagementBusniess
from tools.replace_data import ReplaceData
from tools.read_conf import ReadConf
import HTMLTestRunner_Chart, time

unit_case_file = ReadConf().get_conf('UNITMANAGEMENT').get('unit_management')
unit_uuid_file = ReadConf().get_conf('UNITMANAGEMENTUUID').get(
    'unit_management_uuid')
unit_uuid_data = GetExcelCase(unit_uuid_file, '单位管理').get_dict_data
unit_delete_data = GetExcelCase(unit_case_file, '单位管理删除').get_dict_data


@ddt.ddt
class UnitManangementDelete(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.log = Logger()
        cls.unit_management_b = UnitManagementBusniess()
        cls.replace_unit_delete = ReplaceData(unit_delete_data, unit_case_file,
                                              '单位管理删除')
        cls.replace_unit_delete.replace_data_sheet(unit_uuid_data)
        cls.new_unit_delete_data = GetExcelCase(unit_case_file,
                                                '单位管理查找').get_dict_data
Пример #9
0
'''
import unittest
import ddt
from busniess.InfrastructrueBusniess.infrastructrue_busniess import InfrastructureBusniess
from tools.get_excel_case import GetExcelCase
from tools.log import Logger
from tools.read_conf import ReadConf
from tools.replace_data import ReplaceData
import HTMLTestRunner_Chart
import time

uuid_file = ReadConf().get_conf('INFRASTRUCTUREUUID').get(
    'infrastructure_uuid')
infrastructure_case_file = ReadConf().get_conf('INFRASTRUCTURE').get(
    'infrastructure')
delete_excel_data = GetExcelCase(infrastructure_case_file,
                                 sheetName='楼栋房屋删除').get_dict_data


@ddt.ddt
class InfrastructureDeleteCase(unittest.TestCase):
    # time.sleep(15)

    @classmethod
    def setUpClass(cls) -> None:
        cls.log = Logger()
        cls.infrastructrue_b = InfrastructureBusniess()
        cls.uuid_data = GetExcelCase(uuid_file, '楼栋房屋').get_dict_data
        cls.replace_infrastructure_delete = ReplaceData(
            delete_excel_data, infrastructure_case_file, '楼栋房屋删除')
        cls.replace_infrastructure_delete.replace_data_sheet(cls.uuid_data)
        cls.new_infrastructure_delete_data = GetExcelCase(
'''

import unittest
import ddt
from tools.get_excel_case import GetExcelCase
from tools.log import Logger
from busniess.UnitMagementBusniess.unit_magement_busniess import UnitManagementBusniess
from tools.replace_data import ReplaceData
from tools.read_conf import ReadConf
import HTMLTestRunner_Chart, time

unit_case_file = ReadConf().get_conf('UNITMANAGEMENT').get('unit_management')
infrastructure_uuid_file = ReadConf().get_conf('INFRASTRUCTUREUUID').get('infrastructure_uuid')
unit_uuid_file = ReadConf().get_conf('UNITMANAGEMENTUUID').get('unit_management_uuid')
# 加载uuid
unit_uuid_data = GetExcelCase(unit_uuid_file, '单位管理').get_dict_data
# 加载测试数据
unit_query_data = GetExcelCase(unit_case_file, '单位管理查找').get_dict_data


@ddt.ddt
class UnitManangementQuery(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.log = Logger()
        cls.unit_uuid_file = ReadConf().get_conf('UNITMANAGEMENTUUID').get('unit_management_uuid')
        cls.unit_management_b = UnitManagementBusniess()
        cls.replace_unit_query = ReplaceData(unit_query_data, unit_case_file, '单位管理查找')
        cls.new_infrastructure_uuid_data = GetExcelCase(infrastructure_uuid_file, '楼栋房屋').get_dict_data
        cls.replace_unit_query.replace_data_sheet(cls.new_infrastructure_uuid_data)
        cls.new_unit_query_data = GetExcelCase(unit_case_file, '单位管理查找').get_dict_data
Пример #11
0
        try:
            response = requests.put(url=url, params=params, headers=headers, data=body, json=json_, timeout=10)
            self.log.logger.info('当前请求方式:put 返回值:response')
            return response
        except Exception as e:
            self.log.logger.error(e)
            return False

    def delete(self, **kwargs):
        params = kwargs.get('params')
        headers = kwargs.get('headers')
        url = kwargs.get('url')
        body = kwargs.get('body')
        json_ = kwargs.get('json')
        try:
            response = requests.delete(url=url, params=params, headers=headers, data=body, json=json_, timeout=10)
            self.log.logger.info('当前请求方式:delete 返回值:response')
            self.log.logger.info(f'response:{response.text}')
            return response
        except Exception as e:
            self.log.logger.error(e)
            return False


if __name__ == '__main__':
    g = GetExcelCase()
    d = g.get_dict_data
    r = RequestsFunc()
    res = r.post(**d[0])
    a = json.loads(res.text)
Пример #12
0
# '''
import unittest
import ddt
from busniess.InfrastructrueBusniess.infrastructrue_busniess import InfrastructureBusniess
from tools.get_excel_case import GetExcelCase
from tools.log import Logger
from tools.read_conf import ReadConf
from tools.replace_data import ReplaceData
import HTMLTestRunner_Chart
import time

uuid_file = ReadConf().get_conf('INFRASTRUCTUREUUID').get(
    'infrastructure_uuid')
infrastructure_case_file = ReadConf().get_conf('INFRASTRUCTURE').get(
    'infrastructure')
query_excel_data = GetExcelCase(infrastructure_case_file,
                                sheetName='楼栋房屋查询').get_dict_data


@ddt.ddt
class InfrastructureQueryCase(unittest.TestCase):
    # time.sleep(20)

    @classmethod
    def setUpClass(cls) -> None:
        cls.log = Logger()
        cls.infrastructrue_b = InfrastructureBusniess()
        cls.uuid_data = GetExcelCase(uuid_file, '楼栋房屋').get_dict_data
        cls.replace_infrastructure_query = ReplaceData(
            query_excel_data, infrastructure_case_file, '楼栋房屋查询')
        cls.replace_infrastructure_query.replace_data_sheet(cls.uuid_data)
        cls.new_infrastructure_query_data = GetExcelCase(
                    self.log.logger.debug(f'p_col:{paramas_uid_col}')
                    paramas_uid = eval(uid_sheet[paramas_uid_col -
                                                 2].get('uuid'))
                    self.log.logger.debug(f'uuid:{paramas_uid}')
                    compile_ = re.compile('[0-9a-z]{32}')
                    # 获取须替换行
                    old_paramas_data = case.get('paramas')
                    compile_text = compile_.search(old_paramas_data).group(0)
                    new_paramas_data = old_paramas_data.replace(
                        compile_text, paramas_uid[0])
                    self.write_excel.write(
                        case.get('row') + 1, 4, new_paramas_data)
                    self.log.logger.debug('写入成功')


if __name__ == '__main__':
    old_data = GetExcelCase(
        fileName=
        r'E:\Auto-interface\data\unit_management\unit_management_case.xlsx',
        sheetName='单位管理新增').get_dict_data
    uid_sheet = GetExcelCase(
        fileName=
        r'E:\Auto-interface\data\infrastructure\infrastructure_uuid.xlsx',
        sheetName='楼栋房屋').get_dict_data
    r = ReplaceData(
        old_data,
        write_file_name=
        r'E:\Auto-interface\data\unit_management\unit_management_case.xlsx',
        write_sheet_name='单位管理新增')
    r.replace_data_sheet(uid_sheet=uid_sheet)
Пример #14
0
'''
@Time    : 2020/7/7 9:30
@Author  : MaKaiQiang
@File    : test_login_test_case.py
'''
from public.response_func import ResponseFunc
from tools.get_excel_case import GetExcelCase
from tools.write_conf import WriteConf
from tools.log import Logger
import unittest
import ddt

import HTMLTestRunner_Chart

excel_data = GetExcelCase(
    fileName=r'E:\Auto-interface\data\login\login_case.xlsx',
    sheetName='云平台登录').get_dict_data


@ddt.ddt
class LoginTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.log = Logger()
        cls.res = ResponseFunc()
        cls.write_c = WriteConf()

    @ddt.data(*excel_data)
    @ddt.unpack
    def test_login(self, **kwargs):
        try: