def test_candidate_reserve_fail(self):
     '''候补可抢占单元、候补非抢占单元,锁位失败'''
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''创建候补可抢占单元'''
     create_info = ad_unit.AdUnit.create_ka_candidate_suit_unit()
     response = create_info.json()
     ad_unit_id = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''锁位'''
     reserve_info = ad_unit.AdUnit().reserve_unit(ad_unit_id)
     reserve_response = reserve_info.json()
     self.assertEqual(reserve_response["code"],
                      "AdUnitTypeCanNotReserve",
                      msg='检查锁位失败,则用例通过')
     '''删除单元'''
     ad_unit.AdUnit().delete_unit(ad_unit_id)
     '''创建候补非抢占单元'''
     create_info = ad_unit.AdUnit.create_vacant_non_candidate_suit_unit()
     response = create_info.json()
     ad_unit_id1 = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''锁位'''
     reserve_info = ad_unit.AdUnit().reserve_unit(ad_unit_id1)
     reserve_response = reserve_info.json()
     self.assertEqual(reserve_response["code"],
                      "AdUnitTypeCanNotReserve",
                      msg='检查锁位失败,则用例通过')
     '''删除单元'''
     ad_unit.AdUnit().delete_unit(ad_unit_id1)
Beispiel #2
0
    def test_list_urgent_campaign_success(self):
        """查看急播过期计划,查询结果非空,查询成功"""
        global_demo.GL_DEL_CAMPAIGN_LIST = []
        '''计划下创建一个必播单元'''
        result = ad_unit.AdUnit().create_ka_guaranteed_building_unit(goal_location_num=10)
        ad_unit_id = result.json()['adUnitId']
        ad_campaign_id = result.json()['adCampaignId']
        global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)

        start_date = time_function.GetTime.get_next_next_monday()
        end_date = time_function.GetTime.get_next_next_monday()
        '''锁位'''
        ad_unit.AdUnit().reserve_unit(ad_unit_id)
        '''审核为急播单'''
        ad_campaign.AdCampaign().audit_campaign(ad_campaign_id=ad_campaign_id, contract_no= 'contract_no', contract_type= 'URGENT', brand='',
                                                         industry='', pb_content='', audit_type='')
        '''查询急播过期计划'''

        list_by_ad_unit_campaign = ad_campaign.AdCampaign().unaudit_campaign_list(start_date, end_date, initial_reserved="false", urgent_expired="true")
        '''检查创建的计划在查询列表中'''
        self.assertIn(ad_campaign_id, list_by_ad_unit_campaign, msg='对比相等,则用例通过')

        '''解锁计划,撤销锁位,删除单元,环境恢复'''
        result = ad_campaign.AdCampaign().unlock_campaign(ad_campaign_id)
        self.assertEqual(result.status_code, 200, msg='解锁计划成功,状态码为200则用例通过')
        ad_unit.AdUnit().revert_unit(ad_unit_id)
        ad_unit.AdUnit().delete_unit(ad_unit_id)
 def test_lock_wait_campaign_success(self):
     """锁定计划,计划下有待发布单元,锁定成功,单元状态无变化"""
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     ''' 创建一个计划'''
     refer_id = global_demo.GL_REFER_ID1
     campaign_type = 'KA'
     campaign_name = int(round(time.time() * 1000000))
     result = ad_campaign.AdCampaign.create_campaign(refer_id,
                                                     campaign_name,
                                                     campaign_type,
                                                     note='')
     ad_campaign_id = result.text
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     time.sleep(1)
     '''在计划下创建一个候补单元'''
     tomorrow = time_function.GetTime.get_tomorrow()
     duration_in_second = 5
     frequency = 300
     start_date = tomorrow
     end_date = tomorrow
     ad_unit_type = 'CANDIDATE'
     dsp = False
     suit_codes = global_demo.GL_SUIT_CODES[0]
     ad_campaign_id = ad_campaign_id
     dsp_id = '603fe4897926451ca30e4a2fa8c68ee8'
     target_type = 'SUIT'
     result = ad_unit.AdUnit().create_unit(duration_in_second, frequency,
                                           start_date, end_date,
                                           ad_unit_type, dsp, suit_codes,
                                           ad_campaign_id, dsp_id,
                                           target_type)
     ad_unit_id = result.json()['adUnitId']
     '''确认单元'''
     ad_unit.AdUnit.confirm_unit(ad_unit_id)
     '''获取单元的auditStatus'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     audit_status = result['auditStatus']
     '''锁定计划'''
     result = ad_campaign.AdCampaign().lock_campaign(ad_campaign_id)
     content = result.json()
     self.assertEqual(result.status_code, 200, msg='锁定计划成功,状态码为200则用例通过')
     self.assertEqual(content['success'],
                      True,
                      msg='锁定计划成功,锁定成功状态值为True 则用例通过')
     '''再次获取单元的auditStatus'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     new_audit_status = result['auditStatus']
     '''检查单元审核状态不变'''
     self.assertEqual(audit_status, new_audit_status, msg='单元审核状态不变,用例通过')
     '''解锁计划,撤销锁位,删除单元,环境恢复'''
     result = ad_campaign.AdCampaign().unlock_campaign(ad_campaign_id)
     self.assertEqual(result.status_code, 200, msg='解锁计划成功,状态码为200则用例通过')
     ad_unit.AdUnit().revert_unit(ad_unit_id)
     ad_unit.AdUnit().delete_unit(ad_unit_id)
Beispiel #4
0
 def test_create_guaranteed_city_hours_unit6(self):
     '''创建必播/全城/发布中/today~maxday/7.5*100/小时单元'''
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''创建单元'''
     start_date = time_function.GetTime.get_today()
     end_date = time_function.GetTime.get_max_day()
     duration_in_second = 7.5
     frequency = 100
     goal_location_num = 10
     ad_campaign_type = 'KA'
     ad_unit_type = 'GUARANTEED'
     ad_unit_target_ids = global_demo.GL_CITY_ID
     target_type = 'CITY'
     create_info = ad_unit.AdUnit.create_campaign_and_unit(
         ad_campaign_type,
         ad_unit_type,
         ad_unit_target_ids,
         target_type,
         start_date,
         end_date,
         duration_in_second=duration_in_second,
         goal_location_num=goal_location_num,
         frequency=frequency)
     response = create_info.json()
     ad_unit_id = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''检查创建的单元信息和预期相同'''
     self.assertEqual(response["auditStatus"], "INITIAL", msg='对比相等,则用例通过')
     self.assertEqual(response["adUnitType"],
                      "GUARANTEED",
                      msg='对比相等,则用例通过')
     self.assertFalse(response["dsp"], msg='检查非DSP,则用例通过')
     self.assertEqual(response["adUnitStatus"], "PENDING", msg='对比相等,则用例通过')
     self.assertEqual(response["goalLocationNum"],
                      goal_location_num,
                      msg='对比相等,则用例通过')
     self.assertEqual(response["resourceAreaType"],
                      "SALE",
                      msg='对比相等,则用例通过')
     self.assertEqual(response["publishVersion"], 0, msg='对比相等,则用例通过')
     '''必播项目挑点单元锁位'''
     reserve_info = ad_unit.AdUnit().reserve_unit(ad_unit_id)
     reserve_response = reserve_info.json()
     self.assertTrue(reserve_response["success"], msg='检查锁位成功,则用例通过')
     '''终止单元'''
     terminate_info = ad_unit.AdUnit().terminate_unit(ad_unit_id)
     self.assertEqual(terminate_info.status_code, 200, msg='对比相等,则用例通过')
     '''删除单元'''
     ad_unit.AdUnit().delete_CANDIDATE_unit_fromDB(ad_unit_id)
Beispiel #5
0
 def test_create_guaranteed_building_unit1(self):
     '''创建必播/项目/待发布/tomorrow~nextnextsunday/15*300单元'''
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''创建单元'''
     ad_campaign_type = 'KA'
     ad_unit_type = 'GUARANTEED'
     start_date = time_function.GetTime.get_tomorrow()
     end_date = time_function.GetTime.get_next_next_sunday()
     ad_unit_target_ids = global_demo.GL_BUILDING_IDS
     target_type = 'BUILDING'
     goal_location_num = 10
     create_info = ad_unit.AdUnit.create_campaign_and_unit(
         ad_campaign_type,
         ad_unit_type,
         ad_unit_target_ids,
         target_type,
         start_date,
         end_date,
         goal_location_num=goal_location_num)
     response = create_info.json()
     ad_unit_id = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''检查创建的单元信息和预期相同'''
     self.assertEqual(response["auditStatus"], "INITIAL", msg='对比相等,则用例通过')
     self.assertEqual(response["adUnitType"],
                      "GUARANTEED",
                      msg='对比相等,则用例通过')
     self.assertFalse(response["dsp"], msg='检查非DSP,则用例通过')
     self.assertEqual(response["adUnitStatus"], "PENDING", msg='对比相等,则用例通过')
     self.assertEqual(response["goalLocationNum"],
                      goal_location_num,
                      msg='对比相等,则用例通过')
     self.assertEqual(response["resourceAreaType"],
                      "SALE",
                      msg='对比相等,则用例通过')
     self.assertEqual(response["publishVersion"], 0, msg='对比相等,则用例通过')
     '''必播项目挑点单元锁位'''
     reserve_info = ad_unit.AdUnit().reserve_unit(ad_unit_id)
     reserve_response = reserve_info.json()
     self.assertTrue(reserve_response["success"], msg='检查锁位成功,则用例通过')
     '''撤销锁位'''
     revert_info = ad_unit.AdUnit().revert_unit(ad_unit_id)
     self.assertEqual(revert_info.status_code, 200, msg='对比相等,则用例通过')
     '''删除单元'''
     ad_unit.AdUnit().delete_unit(ad_unit_id)
 def test_guaranteed_confirm_fail(self):
     '''必播单元单元,不支持确认,确认失败'''
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''创建必播意向中单元'''
     create_info = ad_unit.AdUnit.create_ka_guaranteed_suit_unit()
     response = create_info.json()
     ad_unit_id = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''确认'''
     confirm_info = ad_unit.AdUnit().confirm_unit(ad_unit_id)
     confirm_response = confirm_info.json()
     self.assertEqual(confirm_response["code"],
                      "AdUnitTypeCanNotConfirm",
                      msg='检查锁位失败,则用例通过')
     '''删除单元'''
     ad_unit.AdUnit().delete_unit(ad_unit_id)
Beispiel #7
0
 def test_create_candidate_city_unit9(self):
     '''创建空位候补非抢占/全城/发布中/today~maxday/15*300单元'''
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''创建单元'''
     start_date = time_function.GetTime.get_today()
     end_date = time_function.GetTime.get_max_day()
     duration_in_second = 15
     frequency = 300
     goal_location_num = 10
     ad_campaign_type = 'VACANT'
     ad_unit_type = 'CANDIDATE_NON_PREEMPTIVE'
     ad_unit_target_ids = global_demo.GL_CITY_ID
     target_type = 'CITY'
     create_info = ad_unit.AdUnit.create_campaign_and_unit(
         ad_campaign_type,
         ad_unit_type,
         ad_unit_target_ids,
         target_type,
         start_date,
         end_date,
         duration_in_second=duration_in_second,
         frequency=frequency,
         goal_location_num=goal_location_num)
     response = create_info.json()
     ad_unit_id = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''检查创建的单元信息和预期相同'''
     self.assertEqual(response["auditStatus"], "INITIAL", msg='对比相等,则用例通过')
     self.assertEqual(response["adUnitType"],
                      "CANDIDATE_NON_PREEMPTIVE",
                      msg='对比相等,则用例通过')
     self.assertFalse(response["dsp"], msg='检查非DSP,则用例通过')
     self.assertEqual(response["adUnitStatus"], "PENDING", msg='对比相等,则用例通过')
     self.assertEqual(response["resourceAreaType"],
                      "SALE",
                      msg='对比相等,则用例通过')
     self.assertEqual(response["publishVersion"], 0, msg='对比相等,则用例通过')
     '''锁位'''
     ad_unit.AdUnit().confirm_unit(ad_unit_id)
     '''终止单元'''
     terminate_info = ad_unit.AdUnit().terminate_unit(ad_unit_id)
     self.assertEqual(terminate_info.status_code, 200, msg='对比相等,则用例通过')
     '''删除单元'''
     ad_unit.AdUnit().delete_CANDIDATE_unit_fromDB(ad_unit_id)
Beispiel #8
0
 def test_create_property_guaranteed_location_unit14(self):
     '''创建物管挑点必播/发布中/today~maxday/15*300单元'''
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''创建单元'''
     start_date = time_function.GetTime.get_today()
     end_date = time_function.GetTime.get_max_day()
     duration_in_second = 15
     frequency = 300
     ad_campaign_type = 'PROPERTY'
     ad_unit_type = 'GUARANTEED'
     ad_unit_target_ids = global_demo.GL_PROPERTY_LOCATION_IDS
     target_type = 'LOCATION'
     create_info = ad_unit.AdUnit.create_campaign_and_unit(
         ad_campaign_type,
         ad_unit_type,
         ad_unit_target_ids,
         target_type,
         start_date,
         end_date,
         duration_in_second=duration_in_second,
         frequency=frequency)
     response = create_info.json()
     ad_unit_id = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''检查创建的单元信息和预期相同'''
     self.assertEqual(response["auditStatus"], "AUDITED", msg='对比相等,则用例通过')
     self.assertEqual(response["adUnitType"],
                      "GUARANTEED",
                      msg='对比相等,则用例通过')
     self.assertFalse(response["dsp"], msg='检查非DSP,则用例通过')
     self.assertEqual(response["adUnitStatus"], "PENDING", msg='对比相等,则用例通过')
     self.assertEqual(response["resourceAreaType"],
                      "INSTALL",
                      msg='对比相等,则用例通过')
     self.assertEqual(response["publishVersion"], 0, msg='对比相等,则用例通过')
     '''锁位'''
     reserve_info = ad_unit.AdUnit().reserve_unit(ad_unit_id)
     reserve_response = reserve_info.json()
     self.assertTrue(reserve_response["success"], msg='检查锁位成功,则用例通过')
     '''终止单元'''
     terminate_info = ad_unit.AdUnit().terminate_unit(ad_unit_id)
     self.assertEqual(terminate_info.status_code, 200, msg='对比相等,则用例通过')
     '''删除单元'''
     ad_unit.AdUnit().delete_CANDIDATE_unit_fromDB(ad_unit_id)
Beispiel #9
0
    def test_list_unlock_urgent_campaign_success(self):
        """锁位未审核true,急播过期true,查询结果非空"""
        global_demo.GL_DEL_CAMPAIGN_LIST = []

        '''计划下创建一个必播单元'''
        result = ad_unit.AdUnit().create_ka_guaranteed_building_unit(goal_location_num=10)
        ad_unit_id = result.json()['adUnitId']
        ad_campaign_id = result.json()['adCampaignId']
        global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)

        '''锁位'''
        ad_unit.AdUnit().reserve_unit(ad_unit_id)

        '''创建一个计划'''
        result = ad_campaign.AdCampaign.create_campaign(refer_id=global_demo.GL_REFER_ID1,
                                                        campaign_name=int(round(time.time() * 1000000)),
                                                        campaign_type='KA', note='')
        ad_campaign_id1 = result.text
        global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id1)
        time.sleep(1)
        '''急播计划下创建一个候补单元'''

        result = ad_unit.AdUnit().create_ka_candidate_suit_unit()
        ad_unit_id1 = result.json()['adUnitId']
        ad_campaign_id1 = result.json()['adCampaignId']
        global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id1)
        start_date = time_function.GetTime.get_next_next_monday()
        end_date = time_function.GetTime.get_next_next_monday()

        '''锁位'''
        ad_unit.AdUnit().confirm_unit(ad_unit_id1)

        '''审核为急播单'''
        contract_no = 'contract_no'
        contract_type = 'URGENT'
        ad_campaign.AdCampaign().audit_campaign(ad_campaign_id1, contract_no, contract_type, brand='',
                                                         industry='', pb_content='', audit_type='')
        '''查询锁位未审核和急播过期计划'''
        list_by_ad_unit_campaign = ad_campaign.AdCampaign().unaudit_campaign_list(start_date, end_date, initial_reserved="true", urgent_expired="true")
        '''检查创建的计划在查询列表中'''
        self.assertIn(ad_campaign_id, list_by_ad_unit_campaign, msg='对比相等,则用例通过')
        self.assertIn(ad_campaign_id1, list_by_ad_unit_campaign, msg='对比相等,则用例通过')
        
        '''解锁计划,撤销锁位,删除单元,环境恢复'''
        result = ad_campaign.AdCampaign().unlock_campaign(ad_campaign_id)
        self.assertEqual(result.status_code, 200, msg='解锁计划成功,状态码为200则用例通过')
        result = ad_campaign.AdCampaign().unlock_campaign(ad_campaign_id1)
        self.assertEqual(result.status_code, 200, msg='解锁计划成功,状态码为200则用例通过')
        ad_unit.AdUnit().revert_unit(ad_unit_id)
        ad_unit.AdUnit().revert_unit(ad_unit_id1)
        '''删除单元'''
        ad_unit.AdUnit().delete_unit(ad_unit_id)
        ad_unit.AdUnit().delete_unit(ad_unit_id1)
Beispiel #10
0
 def test_list_unlock_campaign_success(self):
     """查看锁位未审核计划,查询结果非空,查询成功"""
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''计划下创建一个候补意向中单元'''
     tomorrow = time_function.GetTime.get_tomorrow()
     result = ad_unit.AdUnit().create_ka_guaranteed_building_unit(goal_location_num=10)
     ad_unit_id = result.json()['adUnitId']
     ad_campaign_id= result.json()['adCampaignId']
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''锁位'''
     ad_unit.AdUnit().reserve_unit(ad_unit_id)
     '''查询锁位未审核计划'''
     list_by_ad_unit_campaign = ad_campaign.AdCampaign().unaudit_campaign_list(start_date=tomorrow, end_date=tomorrow, initial_reserved="true", urgent_expired="false")
     '''检查创建的计划在查询列表中'''
     self.assertIn(ad_campaign_id, list_by_ad_unit_campaign, msg='对比相等,则用例通过')
     '''撤销锁位'''
     ad_unit.AdUnit().revert_unit(ad_unit_id)
     '''删除单元'''
     ad_unit.AdUnit().delete_unit(ad_unit_id)
Beispiel #11
0
    def test_list_unlock_urgent_campaign_fail(self):
        """锁位未审核false,急播过期false,查询结果为空"""
        global_demo.GL_DEL_CAMPAIGN_LIST = []

        '''计划下创建一个必播单元'''
        result = ad_unit.AdUnit().create_ka_guaranteed_building_unit(goal_location_num=10)
        ad_unit_id = result.json()['adUnitId']
        ad_campaign_id = result.json()['adCampaignId']
        global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)

        start_date = time_function.GetTime.get_next_next_monday()
        end_date = time_function.GetTime.get_next_next_monday()
        '''锁位'''
        ad_unit.AdUnit().reserve_unit(ad_unit_id)
        '''审核为急播单'''
        ad_campaign.AdCampaign().audit_campaign(ad_campaign_id=ad_campaign_id, contract_no='contract_no', contract_type='URGENT', brand='',
                                                         industry='', pb_content='', audit_type='')
        '''查询急播过期计划'''
        ad_campaign.AdCampaign().unaudit_campaign_list(start_date, end_date, initial_reserved="false", urgent_expired="false")
        '''撤销锁位'''
        ad_unit.AdUnit().revert_unit(ad_unit_id)
        '''删除单元'''
        ad_unit.AdUnit().delete_unit(ad_unit_id)
Beispiel #12
0
 def test_create_guaranteed_suit_unit4(self):
     '''创建必播/套装/发布中/today~today/15*300单元'''
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''创建单元'''
     start_date = time_function.GetTime.get_today()
     end_date = time_function.GetTime.get_tomorrow()
     ad_campaign_type = 'KA'
     ad_unit_type = 'GUARANTEED'
     ad_unit_target_ids = global_demo.GL_SUIT_CODES
     target_type = 'SUIT'
     create_info = ad_unit.AdUnit.create_campaign_and_unit(
         ad_campaign_type, ad_unit_type, ad_unit_target_ids, target_type,
         start_date, end_date)
     response = create_info.json()
     ad_unit_id = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''检查创建的单元信息和预期相同'''
     self.assertEqual(response["auditStatus"], "INITIAL", msg='对比相等,则用例通过')
     self.assertEqual(response["adUnitType"],
                      "GUARANTEED",
                      msg='对比相等,则用例通过')
     self.assertFalse(response["dsp"], msg='检查非DSP,则用例通过')
     self.assertEqual(response["adUnitStatus"], "PENDING", msg='对比相等,则用例通过')
     self.assertEqual(response["resourceAreaType"],
                      "SALE",
                      msg='对比相等,则用例通过')
     self.assertEqual(response["publishVersion"], 0, msg='对比相等,则用例通过')
     '''锁位'''
     reserve_info = ad_unit.AdUnit().reserve_unit(ad_unit_id)
     reserve_response = reserve_info.json()
     self.assertTrue(reserve_response["success"], msg='检查锁位成功,则用例通过')
     '''终止单元'''
     terminate_info = ad_unit.AdUnit().terminate_unit(ad_unit_id)
     self.assertEqual(terminate_info.status_code, 200, msg='对比相等,则用例通过')
     '''删除单元'''
     ad_unit.AdUnit().delete_CANDIDATE_unit_fromDB(ad_unit_id)
Beispiel #13
0
 def test_audit_pending_campaign_fail(self):
     """计划下有意向中单元,审核失败"""
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     ''' 创建一个计划'''
     refer_id = global_demo.GL_REFER_ID1
     campaign_type = 'KA'
     campaign_name = int(round(time.time() * 1000000))
     result = ad_campaign.AdCampaign.create_campaign(refer_id,
                                                     campaign_name,
                                                     campaign_type,
                                                     note='')
     ad_campaign_id = result.text
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     time.sleep(1)
     '''在计划下创建一个意向中的必播单元'''
     tomorrow = time_function.GetTime.get_tomorrow()
     duration_in_second = 5
     frequency = 300
     start_date = tomorrow
     end_date = tomorrow
     ad_unit_type = 'GUARANTEED'
     dsp = False
     suit_codes = global_demo.GL_SUIT_CODES[0]
     ad_campaign_id = ad_campaign_id
     dsp_id = '603fe4897926451ca30e4a2fa8c68ee8'
     target_type = 'SUIT'
     result = ad_unit.AdUnit().create_unit(duration_in_second, frequency,
                                           start_date, end_date,
                                           ad_unit_type, dsp, suit_codes,
                                           ad_campaign_id, dsp_id,
                                           target_type)
     ad_unit_id = result.json()['adUnitId']
     '''审核计划,审核失败'''
     contract_no = 'contract_no'
     contract_type = 'URGENT'
     result = ad_campaign.AdCampaign().audit_campaign(ad_campaign_id,
                                                      contract_no,
                                                      contract_type,
                                                      brand='',
                                                      industry='',
                                                      pb_content='',
                                                      audit_type='')
     content = result.json()
     self.assertEqual(result.status_code, 200, msg='审核计划失败,状态码为200')
     self.assertEqual(content['success'],
                      False,
                      msg='审核计划失败,审核成功状态值为false 则用例通过')
     ad_unit.AdUnit.delete_unit(ad_unit_id)
 def test_reserve_not_pending_unit(self):
     '''单元状态为“待发布”、“已取消”、“已终止”、“发布中”、“发布完成”,给出提示,无法锁位'''
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''创建待发布单元'''
     create_info = ad_unit.AdUnit.create_ka_guaranteed_suit_unit()
     response = create_info.json()
     ad_unit_id = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     # global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     '''必播项目挑点单元锁位'''
     reserve_info = ad_unit.AdUnit().reserve_unit(ad_unit_id)
     reserve_response = reserve_info.json()
     self.assertTrue(reserve_response["success"], msg='检查锁位成功,则用例通过')
     '''已锁位单元再次锁位'''
     reserve_info_wait = ad_unit.AdUnit().reserve_unit(ad_unit_id)
     reserve_response_wait = reserve_info_wait.json()
     self.assertEqual(reserve_response_wait["code"],
                      "AdUnitStatusCanNotReserve",
                      msg='检查锁位失败,则用例通过')
     '''取消单元'''
     ad_unit.AdUnit.cancel_unit(ad_unit_id)
     '''已取消单元再次锁位'''
     reserve_info_cancel = ad_unit.AdUnit().reserve_unit(ad_unit_id)
     reserve_response_cancel = reserve_info_cancel.json()
     self.assertEqual(reserve_response_cancel["code"],
                      "AdUnitStatusCanNotReserve",
                      msg='检查锁位失败,则用例通过')
     '''创建发布中单元'''
     today = time_function.GetTime.get_today()
     create_info = ad_unit.AdUnit.create_ka_guaranteed_suit_unit(
         start_date=today, end_date=today)
     response = create_info.json()
     ad_unit_id1 = response["adUnitId"]
     ad_campaign_id = response["adCampaignId"]
     '''必播项目挑点单元锁位'''
     reserve_info = ad_unit.AdUnit().reserve_unit(ad_unit_id1)
     reserve_response = reserve_info.json()
     self.assertTrue(reserve_response["success"], msg='检查锁位成功,则用例通过')
     '''发布中单元再次锁位'''
     reserve_info_show = ad_unit.AdUnit().reserve_unit(ad_unit_id1)
     reserve_response_show = reserve_info_show.json()
     self.assertEqual(reserve_response_show["code"],
                      "AdUnitStatusCanNotReserve",
                      msg='检查锁位失败,则用例通过')
     '''终止单元'''
     ad_unit.AdUnit.terminate_unit(ad_unit_id1)
     '''已终止单元再次锁位'''
     reserve_info_cancel = ad_unit.AdUnit().reserve_unit(ad_unit_id1)
     reserve_response_cancel = reserve_info_cancel.json()
     self.assertEqual(reserve_response_cancel["code"],
                      "AdUnitStatusCanNotReserve",
                      msg='检查锁位失败,则用例通过')
 def test_confirm_not_pending_unit(self):
     '''单元状态为“待发布”、“已取消”、“已终止”、“发布中”、“发布完成”,给出提示,无法确认'''
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     '''创建待发布单元'''
     create_info = ad_unit.AdUnit.create_ka_candidate_suit_unit()
     response = create_info.json()
     ad_unit_id = response["adUnitId"]
     confirm_info = ad_unit.AdUnit().confirm_unit(ad_unit_id)
     self.assertEqual(confirm_info.status_code, 200, msg='检查确认成功,则用例通过')
     '''待发布单元再次确认'''
     confirm_info_wait = ad_unit.AdUnit().confirm_unit(ad_unit_id)
     confirm_response_wait = confirm_info_wait.json()
     self.assertEqual(confirm_response_wait["code"],
                      "AdUnitStatusCanNotReserve",
                      msg='检查锁位失败,则用例通过')
     '''取消单元'''
     ad_unit.AdUnit.cancel_unit(ad_unit_id)
     '''已取消单元再次确认'''
     confirm_info_cancel = ad_unit.AdUnit().confirm_unit(ad_unit_id)
     confirm_response_cancel = confirm_info_cancel.json()
     self.assertEqual(confirm_response_cancel["code"],
                      "AdUnitStatusCanNotReserve",
                      msg='检查锁位失败,则用例通过')
     '''创建发布中单元'''
     today = time_function.GetTime.get_today()
     create_info = ad_unit.AdUnit.create_ka_candidate_suit_unit(
         start_date=today, end_date=today)
     response = create_info.json()
     ad_unit_id1 = response["adUnitId"]
     '''必播项目挑点单元锁位'''
     confirm_info = ad_unit.AdUnit().confirm_unit(ad_unit_id1)
     self.assertEqual(confirm_info.status_code, 200, msg='检查确认成功,则用例通过')
     '''发布中单元再次锁位'''
     confirm_info_show = ad_unit.AdUnit().confirm_unit(ad_unit_id1)
     confirm_response_show = confirm_info_show.json()
     self.assertEqual(confirm_response_show["code"],
                      "AdUnitStatusCanNotReserve",
                      msg='检查锁位失败,则用例通过')
     '''终止单元'''
     ad_unit.AdUnit.terminate_unit(ad_unit_id1)
     '''已终止单元再次锁位'''
     confirm_info_cancel = ad_unit.AdUnit().confirm_unit(ad_unit_id1)
     confirm_response_cancel = confirm_info_cancel.json()
     self.assertEqual(confirm_response_cancel["code"],
                      "AdUnitStatusCanNotReserve",
                      msg='检查锁位失败,则用例通过')
Beispiel #16
0
def create_many_campaign():
    for i in range(10000):

        '''创建一个计划'''
        refer_id = '136730'
        campaign_type = 'KA'
        campaign_name = 'lihhtest'+time.strftime("%Y-%m-%d %H_%M_%S")
        result = ad_campaign.AdCampaign.create_campaign(refer_id, campaign_type,campaign_name,  note='')
        ad_campaign_id = result.text
        time.sleep(1)
        for i in range(10):

            '''创建一个候补单元'''
            ad_unit_type ='CANDIDATE'
            ad_unit_target_ids = global_demo.GL_BUILDING_IDS
            target_type = 'BUILDING'
            response = ad_unit.AdUnit().create_pure_unit(ad_campaign_id,ad_unit_type, ad_unit_target_ids, target_type)
            ad_unit_id = response.json().get('adUnitId')

            payload = {}
            '''确认'''
            confirm_unit_url = global_demo.GL_URL_AD_GROUP + '/v1/ad/unit/confirm/' + ad_unit_id
            requests.post(confirm_unit_url, json=payload, headers=global_demo.GL_HEADERS, verify=False)
Beispiel #17
0
 def del_test_unit_version_audit_campaign_success(self):
     """接口返回值不返回version,暂不测试加计划审核锁,计划下单元版本号version的测试,审核计划时,计划的任何一个字段值发生变化,计划下单元version+1,否则version保持不变"""
     global_demo.GL_DEL_CAMPAIGN_LIST = []
     ''' 创建一个计划'''
     refer_id = global_demo.GL_REFER_ID1
     campaign_type = 'KA'
     campaign_name = int(round(time.time() * 1000000))
     result = ad_campaign.AdCampaign.create_campaign(refer_id,
                                                     campaign_name,
                                                     campaign_type,
                                                     note='')
     ad_campaign_id = result.text
     global_demo.GL_DEL_CAMPAIGN_LIST.append(ad_campaign_id)
     time.sleep(1)
     '''在计划下创建一个候补单元'''
     tomorrow = time_function.GetTime.get_tomorrow()
     duration_in_second = 5
     frequency = 300
     start_date = tomorrow
     end_date = tomorrow
     ad_unit_type = 'CANDIDATE'
     dsp = False
     suit_codes = global_demo.GL_SUIT_CODES[0]
     ad_campaign_id = ad_campaign_id
     dsp_id = '603fe4897926451ca30e4a2fa8c68ee8'
     target_type = 'SUIT'
     result = ad_unit.AdUnit().create_unit(duration_in_second, frequency,
                                           start_date, end_date,
                                           ad_unit_type, dsp, suit_codes,
                                           ad_campaign_id, dsp_id,
                                           target_type)
     ad_unit_id = result.json()['adUnitId']
     '''确认单元'''
     ad_unit.AdUnit.confirm_unit(ad_unit_id)
     '''获取单元的version'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     version = result['version']
     '''1:审核计划类型为合同,审核成功,检查单元版本号+1'''
     contract_no = 'contract_no'
     contract_type = 'CONTRACT'
     ad_campaign.AdCampaign().audit_campaign(ad_campaign_id,
                                             contract_no,
                                             contract_type,
                                             brand='',
                                             industry='',
                                             pb_content='',
                                             audit_type='')
     '''再次获取单元的publishVersion'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     new_version = result['version']
     '''检查版本号+1'''
     self.assertEqual(new_version, version + 1, msg='审核计划成功,状态码为200')
     version = new_version
     '''2: 不解锁,再次审核计划,合同信息无任何变化,审核成功,检查单元版本号不变'''
     contract_no = 'contract_no'
     contract_type = 'CONTRACT'
     ad_campaign.AdCampaign().audit_campaign(ad_campaign_id,
                                             contract_no,
                                             contract_type,
                                             brand='',
                                             industry='',
                                             pb_content='',
                                             audit_type='')
     '''再次获取单元的publishVersion'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     new_version = result['version']
     '''检查版本号不变'''
     self.assertEqual(new_version, version, msg='审核计划成功,状态码为200')
     '''3: 不解锁,再次审核计划,修改合同号,审核成功,检查单元版本号+1'''
     contract_no = 'contract_no1'
     contract_type = 'CONTRACT'
     ad_campaign.AdCampaign().audit_campaign(ad_campaign_id,
                                             contract_no,
                                             contract_type,
                                             brand='',
                                             industry='',
                                             pb_content='',
                                             audit_type='')
     '''再次获取单元的version'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     new_version = result['version']
     '''检查版本号+1'''
     self.assertEqual(new_version, version + 1, msg='审核计划成功,状态码为200')
     version = new_version
     '''4: 不解锁,再次审核计划,修改合同类型为急播单,审核成功,检查单元版本号+1'''
     contract_no = 'contract_no1'
     contract_type = 'URGENT'
     ad_campaign.AdCampaign().audit_campaign(ad_campaign_id,
                                             contract_no,
                                             contract_type,
                                             brand='',
                                             industry='',
                                             pb_content='',
                                             audit_type='')
     '''再次获取单元的version'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     new_version = result['version']
     '''检查版本号+1'''
     self.assertEqual(new_version, version + 1, msg='审核计划成功,状态码为200')
     version = new_version
     '''5: 不解锁,再次审核计划,修改brand,审核成功,检查单元版本号+1'''
     contract_no = 'contract_no1'
     contract_type = 'CONTRACT'
     brand = 'test1'
     ad_campaign.AdCampaign().audit_campaign(ad_campaign_id,
                                             contract_no,
                                             contract_type,
                                             brand,
                                             industry='',
                                             pb_content='',
                                             audit_type='')
     '''再次获取单元的version'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     new_version = result['version']
     '''检查版本号+1'''
     self.assertEqual(new_version, version + 1, msg='审核计划成功,状态码为200')
     version = new_version
     '''6: 不解锁,再次审核计划,修改industry,审核成功,检查单元版本号+1'''
     contract_no = 'contract_no1'
     contract_type = 'CONTRACT'
     brand = 'brand'
     industry = 'industry'
     ad_campaign.AdCampaign().audit_campaign(ad_campaign_id,
                                             contract_no,
                                             contract_type,
                                             brand,
                                             industry,
                                             pb_content='',
                                             audit_type='')
     '''再次获取单元的version'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     new_version = result['version']
     '''检查版本号+1'''
     self.assertEqual(new_version, version + 1, msg='审核计划成功,状态码为200')
     version = new_version
     '''7: 不解锁,再次审核计划,修改pb_content,审核成功,检查单元版本号+1'''
     contract_no = 'contract_no1'
     contract_type = 'CONTRACT'
     brand = 'brand'
     industry = 'industry'
     pb_content = 'pb_content'
     ad_campaign.AdCampaign().audit_campaign(ad_campaign_id,
                                             contract_no,
                                             contract_type,
                                             brand,
                                             industry,
                                             pb_content,
                                             audit_type='')
     '''再次获取单元的version'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     new_version = result['version']
     '''检查版本号+1'''
     self.assertEqual(new_version, version + 1, msg='审核计划成功,状态码为200')
     version = new_version
     '''8: 不解锁,再次审核计划,修改audit_type,审核成功,检查单元版本号+1'''
     contract_no = 'contract_no1'
     contract_type = 'CONTRACT'
     brand = 'brand'
     industry = 'industry'
     pb_content = 'pb_content'
     audit_type = 'audit_type'
     ad_campaign.AdCampaign().audit_campaign(ad_campaign_id, contract_no,
                                             contract_type, brand, industry,
                                             pb_content, audit_type)
     '''再次获取单元的version'''
     result = ad_unit.AdUnit.get_unit_info(ad_unit_id)
     new_version = result['version']
     '''检查版本号+1'''
     self.assertEqual(new_version, version + 1, msg='审核计划成功,状态码为200')
     '''环境恢复:解锁计划、撤销锁位、并删除单元'''
     ad_campaign.AdCampaign().unlock_campaign(ad_campaign_id)
     ad_unit.AdUnit.revert_unit(ad_unit_id)
     del_result = ad_unit.AdUnit.delete_unit(ad_unit_id)
     self.assertEqual(del_result, True, msg='单元删除成功')