Exemple #1
0
 def test_001_device(self):
     # 获取设备类型信息
     r1 = json.loads(f.test_device_getDeviceType())
     a.verity(r1['data'][0]['dictCode'], '1', '断言dictCode')
     a.verity(r1['data'][0]['dictName'], '有线', '断言dictName')
     a.verity(r1['data'][0]['id'], 20, '断言id')
     a.verity(r1['data'][1]['dictCode'], '0', '断言dictCode')
     a.verity(r1['data'][1]['dictName'], '无线', '断言dictName')
     a.verity(r1['data'][1]['id'], 21, '断言id')
     # 获取设备型号信息
     r2 = json.loads(f.test_device_getDeviceMoudel(''))
     a.verity(r2['data'][0]['dictLevel'], 0, '断言dictLevel')
     a.verity(r2['data'][0]['dictName'], 'TK115', '断言dictName')
     a.verity(r2['data'][0]['id'], 22, '断言id')
     a.verity(r2['data'][1]['dictLevel'], 1, '断言dictLevel')
     a.verity(r2['data'][1]['dictName'], 'SZ-K3', '断言dictName')
     a.verity(r2['data'][1]['id'], 23, '断言id')
     a.verity(r2['data'][2]['dictLevel'], 1, '断言dictLevel')
     a.verity(r2['data'][2]['dictName'], 'GV25', '断言dictName')
     a.verity(r2['data'][2]['id'], 54, '断言id')
     a.verity(r2['data'][3]['dictLevel'], 0, '断言dictLevel')
     a.verity(r2['data'][3]['dictName'], 'GT740', '断言dictName')
     a.verity(r2['data'][3]['id'], 55, '断言id')
     # 获取机构信息
     r3 = json.loads(f.test_device_getLowerOrg())
     a.verity(r3['data'][0]['orgCode'], orgCode, '断言orgCode')
     a.verity(r3['data'][0]['name'], c.companyName, '断言组织机构名称')
     # 保存设备记录
     f.test_device_save('', orgCode, c.devicetypecode,
                        c.devicemoudelCode, c.deviceCode, '001', tf.getnow_day())
     device_id = fs.get_device_id(c.deviceCode)
     # 更新设备记录
     f.test_device_update(device_id, orgCode, c.devicetypecode,
                          c.devicemoudelCode, c.deviceCode, '001', tf.getnow_day())
     # 设备列表
     r4 = json.loads(f.test_device_list('', 1, 10))
     a.verity(r4['data']['pageNum'], 1, '断言pageNum')
     a.verity(r4['data']['pageSize'], 10, '断言pageSize')
     a.verityContain(r4['data']['record'], c.deviceCode, '断言修改后的deviceCode')
     # 获取设备详情
     r5 = json.loads(f.test_device_detail(device_id))
     a.verity(r5['data']['deviceCode'], c.deviceCode, '断言deviceCode')
     a.verity(r5['data']['id'], device_id, '断言device_id')
     a.verity(r5['data']['moudelCode'], c.devicemoudelCode, '断言moudelCode')
     a.verity(r5['data']['orgCode'], orgCode, '断言orgCode')
     a.verity(r5['data']['typeCode'], c.devicetypecode, '断言typeCode')
     # 删除设备记录
     f.test_device_delete(device_id)
Exemple #2
0
 def test_014_gps(self):
     gpsid, gpscode = fs.get_gps()[0]
     finance_id = fs.get_car_id(c.car_owner)
     # 获取机构信息
     r = json.loads(f.test_install_getLowerOrg())
     a.verity(r['data'][0]['name'], c.companyName)
     a.verity(r['data'][0]['orgCode'], orgCode)
     # 获取GPS设备
     f.test_install_getDevice(gpscode, orgCode)
     # 获取GPS类型
     f.test_install_getGpsType()
     # 获取GPS型号
     f.test_install_getGpsMoudel('有线')
     f.test_install_getGpsMoudel('无线')
     # 根据所在机构获取GPS设备信息
     r1 = json.loads(f.test_install_getDeviceByOrgCode(gpsid, orgCode))
     a.verityContain(r1['data'], gpscode)
     a.verityContain(r1['data'], str(gpsid))
     # 安装车辆搜索联想
     r2 = json.loads(f.test_install_installCarSearchAssociate(c.car_owner, orgCode))
     a.verity(r2['data'][0]['fid'], finance_id)
     a.verity(r2['data'][0]['carNo'], c.carNo)
     a.verity(r2['data'][0]['carNoAndOwner'], c.carNo + ' ' + c.car_owner)
     # 设备安装  保存GPS安装记录
     r3 = json.loads(f.test_install_saveGpsInstallRecord(finance_id, gpsid, '', '1', '1', tf.getnow_day()))
     gps_finance_id = fs.get_gps_finance_id(gpsid, finance_id)
     a.verity(r3['data'], gps_finance_id)
     # 获取GPS安装记录详情
     r4 = json.loads(f.test_install_getGpsInstallDetail(gps_finance_id))
     a.verity(r4['data']['id'], gps_finance_id)
     a.verity(r4['data']['orgCode'], orgCode)
     a.verity(r4['data']['financeId'], finance_id)
     a.verity(r4['data']['gpsId'], gpsid)
     a.verity(r4['data']['gpsCode'], gpscode)
     a.verityIn(r4['data']['installDate'], str(tf.getnow_day()))
     # 根据所在机构获取GPS设备信息
     f.test_install_getDeviceByOrgCode('', orgCode)
     # 更新GPS安装记录
     f.test_install_updateGpsInstallRecord(finance_id, gpsid, gps_finance_id, '2', '2', tf.getnow_day())
     # Gps安装记录列表
     f.test_install_findGpsInstallRecord('', 1, 10)
     # 拆机,将gps安装记录拆除
     f.test_install_dismantle(gps_finance_id)
     f.test_install_saveGpsInstallRecord(finance_id, gpsid, '', '1', '1', tf.getnow_day())
     gps_finance_id = fs.get_gps_finance_id(gpsid, finance_id)
     # 删除安装记录,安装记录出错了,将错误数据删除
     f.test_install_deleteRecord(gps_finance_id)
Exemple #3
0
def get_select_info(rap, version_id):
    """
    获取查询信息
    :param rap: rap数据
    :param version_id: 版本信息
    :return: 查询列 select_col, 数据字典 value_dict
    """
    is_exe, update_date = 'N', TimeFormat.getnow_day()
    select_col = ['dict_id', 'module', 'page', 'page_name', 'api_name', 'api_type', 'api_address', 'parameters',
                  'parameter_description', 'response_parameter', 'response_parameter_description']
    value_dict = dict(zip(select_col, rap))
    if version_id != '':
        value_dict['version_id'] = version_id
    value_dict['is_exe'] = is_exe
    value_dict['update_date'] = update_date
    value_dict['api_name'] = re.sub('[\n\t\r]', '', value_dict['api_name'])
    if value_dict['dict_id'] == 1 and 'manage' in value_dict['api_name']:
        value_dict['module'] = 'manage'
    select_col.insert(1, 'version_id')
    LOG.debug('查询列{}'.format(select_col))
    LOG.debug('数据字典{}'.format(value_dict))
    return select_col, value_dict
 def test_005_device_update(self):
     device_id = fs.get_device_id(c.deviceCode)
     # 更新设备记录
     f.test_device_update(device_id, orgCode, c.devicetypecode,
                          c.devicemoudelCode, c.deviceCode, '001',
                          tf.getnow_day())
 def test_004_device_save(self):
     # 保存设备记录
     f.test_device_save('', orgCode, c.devicetypecode, c.devicemoudelCode,
                        c.deviceCode, '001', tf.getnow_day())
def modif(data, modif_key, modif_value):
    """
    修改请求数据
    :param data: 请求数据
    :param modif_key:  修改请求数据参数
    :param modif_value: 修改值
    :return:
    carrier: 运营商类型 (联通、移动、电信)
    open_time: 开户时长 (天)
    sex:男,女
    age: 年龄
    total_fee:账期内所有费用
    web_fee:网络流量消费金额(分)
    voice_fee:通话消费金额(分)
    sms_fee:短信消费金额(分)
    extra_service_fee:增值业务消费金额(分)
    extra_fee:其它消费金额(分)
    base_fee:基础消费金额
    sms_cnt:短信次数 (数字)
    sms_fees:短信费用
    location:朋友圈中心城市
    peer_number:朋友联系数量
    location_type:号码类型;国内通话
    dial_type:主叫,被叫 DAIL,DAILED
    duration: 通话时长(秒)
    fee: 通话费用
    time: 通话时段 (早晨,上午,中午,下午,傍晚,晚上,凌晨,深夜)
        早晨(5:30:00-9:00:00)
        上午(9:00:00-11:30:00)
        中午(11:30:00-13:30:00)
        下午(13:30:00-17:30:00)
        傍晚(17:30:00-19:30:00)
        晚上(19:30:00-23:30:00)
        凌晨(23:30:00-01:30:00)
        深夜(01:30:00-05:30:00)
    time2: 通话时段
        早晨(5:30-11:30)
        中午(11:30-13:30)
        下午(13:30-17:30)
        晚上(17:30-23:30)
        凌晨(23:30-5:30)
    time3: 通话时段 0-7点,不用输入参数修改值
    total_size:通话次数
    bill_month:通话月份 (7,1,3,6)
    calls: 通话信息条数 (数字)
    """
    if re.sub('\s+', '', modif_value) == '':
        modif_value = 'null'
    if modif_key == 'carrier':
        # modif_value 输入 联通、移动、电信
        if modif_value in carriers.keys():
            modif_value = carriers[modif_value]
        data["carrier"] = modif_value
    elif modif_key == 'open_time':
        # 输入数字,距离当前时间的天数
        if modif_value.isdigit():
            modif_value = TimeFormat.get_day_around(-int(modif_value))
        data["open_time"] = modif_value
    elif modif_key == 'sex':
        # 输入男、女,自动生成 idcard
        idcard = list(data["idcard"])
        if modif_value == '女':
            v = random.choice('02468')
            idcard[16] = str(v)
            data["idcard"] = ''.join(idcard)
        elif modif_value == '男':
            v = random.choice('13579')
            idcard[16] = str(v)
            data["idcard"] = ''.join(idcard)
        else:
            data["idcard"] = modif_value
    elif modif_key == 'age':
        # 输入年龄,自动生成 idcard
        if modif_value.isdigit():
            idcard = list(data["idcard"])
            time_now = TimeFormat.getnow_day()
            year, month, day = time_now.split('-')
            y = int(year) - int(modif_value)
            idcard[6:14] = ''.join([str(y), month, day])
            data["idcard"] = ''.join(idcard)
        else:
            data["idcard"] = modif_value
    elif modif_key == 'city':
        data["city"] = modif_value
    elif modif_key == 'total_fee':
        data["bills"][0]["total_fee"] = modif_value
    elif modif_key == 'web_fee':
        data["bills"][0]["web_fee"] = modif_value
    elif modif_key == 'voice_fee':
        data["bills"][0]["voice_fee"] = modif_value
    elif modif_key == 'sms_fee':
        data["bills"][0]["sms_fee"] = modif_value
    elif modif_key == 'extra_service_fee':
        data["bills"][0]["extra_service_fee"] = modif_value
    elif modif_key == 'extra_fee':
        data["bills"][0]["extra_fee"] = modif_value
    elif modif_key == 'base_fee':
        data["bills"][0]["base_fee"] = modif_value
    elif modif_key == 'sms_cnt':
        # 输入数字, 自动生成对应数字的短信条数
        if modif_value.isdigit():
            sms = data['smses'][0]
            data['smses'] = [sms for _ in range(int(modif_value))]
        else:
            data['smses'] = []
    elif modif_key == 'sms_fees':
        data['smses'][0]['items'][0]['fee'] = modif_value
    elif modif_key == 'location':
        data["calls"][0]['items'][0]['location'] = modif_value
    elif modif_key == 'peer_number':
        data["calls"][0]['items'][0]['peer_number'] = modif_value
    elif modif_key == 'location_type':
        data["calls"][0]['items'][0]['location_type'] = modif_value
    elif modif_key == 'dial_type':
        # 输入 DAIL 或者 DAILED
        calls = data["calls"][0]
        call = copy.deepcopy(calls)
        call['items'][0]['dial_type'] = modif_value
        data["calls"][0] = call
    elif modif_key == 'duration':
        if modif_value.isdigit():
            modif_value = int(modif_value)
        data["calls"][0]['items'][0]['duration'] = modif_value
    elif modif_key == 'fee':
        data["calls"][0]['items'][0]['fee'] = modif_value
    elif modif_key == 'time':
        # 输入时间段
        #         早晨(5:30:00-9:00:00)
        #         上午(9:00:00-11:30:00)
        #         中午(11:30:00-13:30:00)
        #         下午(13:30:00-17:30:00)
        #         傍晚(17:30:00-19:30:00)
        #         晚上(19:30:00-23:30:00)
        #         凌晨(23:30:00-01:30:00)
        #         深夜(01:30:00-05:30:00)
        if modif_value in ('早晨', '上午', '中午', '下午', '傍晚', '晚上', '凌晨', '深夜'):
            sev_time = data["calls"][0]['items'][0]['time']
            sev_day = sev_time.split(' ')[0]
            data["calls"][0]['items'][0]['time'] = get_time_step(
                sev_day, modif_value)
        else:
            data["calls"][0]['items'][0]['time'] = modif_value
    elif modif_key == 'time2':
        # 输入时间段
        #         早晨(5:30-11:30)
        #         中午(11:30-13:30)
        #         下午(13:30-17:30)
        #         晚上(17:30-23:30)
        #         凌晨(23:30-5:30)
        if modif_value in ('早晨', '中午', '下午', '晚上', '凌晨'):
            sev_time = data["calls"][0]['items'][0]['time']
            sev_day = sev_time.split(' ')[0]
            data["calls"][0]['items'][0]['time'] = get_time_step2(
                sev_day, modif_value)
        else:
            data["calls"][0]['items'][0]['time'] = modif_value
    elif modif_key == 'time3':
        # 输入时间段, 不用输入修改参数值, 直接获取 0-7点
        sev_time = data["calls"][0]['items'][0]['time']
        sev_day = sev_time.split(' ')[0]
        data["calls"][0]['items'][0]['time'] = get_time_step07(sev_day)
    elif modif_key == 'total_size':
        if modif_value.isdigit():
            modif_value = int(modif_value)
        data["calls"][0]['total_size'] = modif_value
    elif modif_key == 'bill_month':
        # 输入修改的月份 7,1,3,6; 7代表7天,其余的都是月份
        times = data["calls"][0]['items'][0]['time']
        time_hmc = times.split(' ')[-1]
        if modif_value == '7':
            start_day = TimeFormat.get_day_around(-7)
            bill_month = '-'.join(start_day.split('-')[:2])
            month_start_date, month_end_date = TimeFormat.get_FirstAndLastDay_month(
                bill_month)
            e_time = start_day + ' ' + time_hmc
            e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
            n_hms = TimeFormat.getnow().split(' ')[-1]
            n_time_num = int(
                TimeFormat.string_toTimestamp_13(start_day + ' ' + n_hms))
            if e_time_num <= n_time_num:
                e_time = TimeFormat.get_day_around(1,
                                                   start_day) + ' ' + time_hmc
            data["calls"][0]['bill_month'] = bill_month
            data["calls"][0]['items'][0]['time'] = e_time
            data["smses"][0]['bill_month'] = bill_month
            data["smses"][0]['items'][0]['time'] = e_time.replace(' ', '-')
            data["bills"][0]['bill_month'] = bill_month
            data["bills"][0]['bill_start_date'] = month_start_date
            data["bills"][0]['bill_end_date'] = month_end_date
        elif modif_value in ('1', '3', '6'):
            month_day = TimeFormat.get_month_day_ago(int(modif_value))
            year, month, day = month_day.split('-')
            bill_month = year + '-' + month
            month_start_date, month_end_date = TimeFormat.get_FirstAndLastDay_month(
                bill_month)
            data["calls"][0]['bill_month'] = bill_month
            e_time = month_day + ' ' + time_hmc
            e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
            n_hms = TimeFormat.getnow().split(' ')[-1]
            n_time_num = int(
                TimeFormat.string_toTimestamp_13(month_day + ' ' + n_hms))
            if e_time_num <= n_time_num:
                e_time = TimeFormat.get_day_around(1,
                                                   month_day) + ' ' + time_hmc
            data["calls"][0]['items'][0]['time'] = e_time
            data["smses"][0]['bill_month'] = bill_month
            data["smses"][0]['items'][0]['time'] = e_time.replace(' ', '-')
            data["bills"][0]['bill_month'] = bill_month
            data["bills"][0]['bill_start_date'] = month_start_date
            data["bills"][0]['bill_end_date'] = month_end_date
        else:
            data["calls"][0]['bill_month'] = modif_value
            data["smses"][0]['bill_month'] = modif_value
            data["bills"][0]['bill_month'] = modif_value
    elif modif_key == 'calls':
        # 输入数字,自动生成通话条数
        if modif_value.isdigit():
            calls = data["calls"][0]
            call = copy.deepcopy(calls)
            data["calls"] = [call for _ in range(int(modif_value))]
        else:
            data["calls"] = []