示例#1
0
 def _add_promotions(self,dict_rulejson,sheet_index,row,coo):
     # 获取excel中的请求数据
     getInputData = self.excel_facade.get_case_input(self.filename, sheet_index=sheet_index, row_id=row)
     # 处理excel中的请求数据
     dict1_input = json.loads(getInputData)
     tmp_result = json.loads(getInputData)
     if dict_rulejson is not None and dict_rulejson != {} :
         for i in dict_rulejson.keys():
             tmp_result[i] = dict_rulejson[i]
     tmp_result['scopeLst'] = json.dumps(tmp_result['scopeLst'])
     tmp_result['priceLst'] = json.dumps(tmp_result['priceLst'])
     tmp_result['ruleJson'] = json.dumps(tmp_result['ruleJson'])
     promotionCode = Module_Pass().get_currentTime2()
     tmp_result['promotionCode'] = promotionCode
     # 获取结果
     result = self.excel_facade.get_case_data_crm(self.filename, sheet_index=sheet_index, row_id=row,
                                                  data=tmp_result,
                                                  coo=coo)
     # 从结果中获取响应信息
     result_response = json.loads(result[1][0])
     promotionid = result_response['data']['promotionIDStr']
     # 从结果中获取excel中期望结果的数据
     result_excel = json.loads(result[0])
     # 进行接口结果断言
     assert result_response['code'] == result_excel['code']
     return promotionid, promotionCode,dict1_input
    def test_5(self):
        # 删除所有活动
        self.promotionUtils._del_all_promotion_v2()
        # 清除缓存
        self.promotionUtils._clear_info_cache_v2(startDate)
        global lst_bargainprice5, lst_bargainprice52, lst_promotionid5, lst_promotioncode5, lst_price5, lst_price52, lst_response5
        lst_bargainprice5 = [21, 22, 233.2, 23.5, 10.19, 5.0, 66666]
        lst_bargainprice52 = [19, 21, 233.3, 23.7, 6, 3.5, 66668]
        lst_price5 = [21.5, 88.8, 233.3, 23.6, 10.2, 5.1, 66666.6]
        lst_price52 = [21, 21.4, 233.4, 23.8, 10.2, 5.1, 86666.6]
        lst_response5 = []
        lst_promotionid5 = []
        lst_promotioncode5 = []
        for i in range(0, len(lst_price5)):
            # 获取excel中的请求数据
            getInputData = self.excel_facade.get_case_input(self.filename, sheet_index=5, row_id=2)
            # 处理excel中的请求数据
            tmp_result = json.loads(getInputData)
            tmp_result['priceLst'][0]['price'] = lst_bargainprice5[i]
            tmp_result['priceLst'][1]['price'] = lst_bargainprice52[i]
            tmp_result['priceLst'] = json.dumps(tmp_result['priceLst'])
            promotionCode = Module_Pass().get_currentTime2()
            tmp_result['promotionCode'] = promotionCode
            lst_promotioncode5.append(promotionCode)
            # 获取结果
            result = self.excel_facade.get_case_data_crm(self.filename, sheet_index=5, row_id=2, data=tmp_result,
                                                         coo=coo)
            # 从结果中获取响应信息
            result_response = json.loads(result[1][0])
            lst_promotionid5.append(result_response['data']['promotionIDStr'])
            # 从结果中获取excel中期望结果的数据
            result_excel = json.loads(result[0])
            # 进行接口结果断言
            assert result_response['code'] == result_excel['code']

            print "***这是第[" + str(i) + "]条请求sass营销计算接口***"
            # 获取excel中的请求数据
            getInputData = self.excel_facade.get_case_input(self.filename, sheet_index=5, row_id=3)
            # 处理excel中的请求数据
            tmp_result = json.loads(getInputData)
            tmp_result['foodLst'][0]['count'] = str(lst_price5[i])  # 菜品1数量
            tmp_result['foodLst'][0]['price'] = str(lst_price5[i])  # 菜品1价格
            tmp_result['foodLst'][1]['count'] = str(lst_price52[i])  # 菜品2数量
            tmp_result['foodLst'][1]['price'] = str(lst_price52[i])  # 菜品2价格
            # 获取结果
            result = self.excel_facade.get_case_data_crm(self.filename, sheet_index=5, row_id=3, data=tmp_result)
            # 从结果中获取响应信息
            result_response = json.loads(result[1][0])
            lst_response5.append(result_response)
            # 从结果中获取excel中期望结果的数据
            result_excel = json.loads(result[0])
            # 进行接口结果断言
            assert result_response['code'] == result_excel['code']

            # 删除所有活动
            self.promotionUtils._del_all_promotion_v2()
            # 清除缓存
            self.promotionUtils._clear_info_cache_v2(startDate)
示例#3
0
 def setup_class(cls):
     _file_name = 'test_saas'
     cls.filename = "../data/%s.xlsx" % _file_name
     cls.promotionUtils = promotion_utils.PromotionUtils()
     cls.excel_facade = excel_case_facade.GetExcelCaseDate()
     cls.str_util = str_utils.StrUtils()
     global coo, sheet_index
     sheet_index = 15
     coo = cls.promotionUtils._login()
     global startDate
     startDate = Module_Pass().get_currentDate()
 def setup_class(cls):
     _file_name = '/test_saas.xlsx'
     _file_path = get_current_path.get_cur_path()
     cls.filename = _file_path + _file_name
     print _file_path
     cls.promotionUtils = promotion_utils.PromotionUtils()
     cls.excel_facade = excel_case_facade.GetExcelCaseDate()
     cls.str_util = str_utils.StrUtils()
     global coo
     coo = cls.promotionUtils._login()
     global startDate
     startDate = Module_Pass().get_currentDate()