Ejemplo n.º 1
0
 def test_campaign_list_kw(self):
     print('kw关键字正常校验')
     kw = ['', '商店', 100030663, 'hfdsajdkas', '1234hhh']
     data = {
         "customerId": self.customerId,
         # "kw": "非商店",
         "sdate": Time().count_datetime(self.time, self.sub),
         "edate": Time().count_datetime(self.time, self.sub)
     }
     data.update({"signId": self.signId})
     for i in range(len(kw)):
         data.update({"kw": kw[i]})
         url = GenerateURL().generate_url(u=str(self.uri + self.port),
                                          d=data)
         request = Client(url).send_request().json()
         self.assertTrue(request['success'])
         self.assertEqual(request['code'], 0)
         r = False
         # if kw[i] != '' or not isinstance(kw[i], int):
         #     for j in range(len(request['result']['list'])):
         #         for keys, values in request['result']['list'][j].items():
         #             if request['result']['list'][j] and keys == 'name' and kw[i] in values:
         #                 r = True
         #     self.assertTrue(r)
         if request['result']['list']:
             for j in range(len(request['result']['list'])):
                 for key, value in request['result']['list'][j].items():
                     if kw[i] != '' or not isinstance(kw[i], int):
                         if key == 'name' and kw[i] in value:
                             r = True
                     if kw[i] != '' and isinstance(kw[i], int):
                         if key == 'id' and kw[i] == value:
                             r = True
                 self.assertTrue(r)
Ejemplo n.º 2
0
 def test_campaign_info_without_campaignId(self):
     data = {"customerId": self.customerId}
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertFalse(json['success'])
     self.assertEqual(json['desc'], 'campaignId参数不能为空')
Ejemplo n.º 3
0
 def test_account_balance_base(self):
     data = {"customerId": self.customerId}
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
Ejemplo n.º 4
0
 def test_campaign_info_base(self):
     data = {"customerId": self.customerId, "campaignId": self.campaignId}
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
     self.assertEqual(str(json['result']['id']), str(data["campaignId"]))
Ejemplo n.º 5
0
 def test_campaign_list_status(self):
     data = {
         "customerId": self.customerId,
         "status": "1",
         "sdate": Time().count_datetime(self.time, self.sub),
         "edate": Time().count_datetime(self.time, self.sub)
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url).send_request()
     self.assertEqual(200, request.status_code)
Ejemplo n.º 6
0
 def test_campaign_edit_budget_campaignid(self):
     data = {
         "customerId": self.customerId,
         "campaignId": RandomId.get_num(1000, 100000),
         "newval": "1000"
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertFalse(json['success'])
Ejemplo n.º 7
0
 def test_creative_edit_list_base(self):
     data = {
         "customerId": self.customerId,
         "creativeIds": str(self.creativeId1) + "," + str(self.creativeId2),
         "newval": "2"
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
 def test_report_audience_gender_data_base(self):
     data = {
         "customerId": self.customerId,
         "sdate": Time().count_datetime(self.time, self.sub),
         "edate": Time().count_datetime(self.time, self.sub)
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
Ejemplo n.º 9
0
 def test_campaign_list_sdate(self):
     data = {
         "customerId": self.customerId,
         "sdate": Time().count_datetime(self.time, self.sub),
         "edate": Time().count_datetime(self.time, self.sub)
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url).send_request()
     json = request.json()
     self.assertEqual(0, json['code'])
     self.assertTrue(json['success'], msg='返回正常')
Ejemplo n.º 10
0
 def test_account_balance_base(self):
     data = {"agent": self.agentId}
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     if request:
         json = request.json()
         self.assertTrue(json['success'])
         for i in range(len(json['result']['list'])):
             for key, value in json['result']['list'][i].items():
                 if key == 'customerId' and value == self.customerId:
                     self.assertTrue(True)
Ejemplo n.º 11
0
 def test_creative_edit_bid_base(self):
     data = {
         "customerId": self.customerId,
         "creativeId": self.creativeId,
         "bidding": "{\"bid\":2,\"billingType\":1}"
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     print(json)
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
Ejemplo n.º 12
0
 def test_campaign_list_base(self):
     print("获取广告计划列表基础请求")
     data = {
         "customerId": self.customerId,
         "sdate": Time().count_datetime(self.time, self.sub),
         "edate": Time().count_datetime(self.time, self.sub)
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertTrue(json['success'])
     self.assertEqual(str(json['code']), str(0))
Ejemplo n.º 13
0
 def test_campaign_edit_status_more_campaignid(self):
     data = {
         "customerId": self.customerId,
         "campaignIds": self.campaignId,
         "newval": "2"
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
     self.assertTrue(str(json['result'][0]['id']) in data['campaignIds'])
Ejemplo n.º 14
0
 def test_account_edit_newDayThreshold_err(self):
     data = {
         "customerId": self.customerId,
     }
     shold = ('199', '199.99', '100000001', '100000000.01', '', '  ')
     for k in range(shold.__len__()):
         data.update({"newDayThreshold": shold[k]})
         data.update({"signId": self.signId})
         url = GenerateURL().generate_url(u=str(self.uri + self.port),
                                          d=data)
         request = Client(url, method=self.method).send_request()
         json = request.json()
         self.assertFalse(json['success'])
         self.assertEqual(20, json['code'])
Ejemplo n.º 15
0
 def test_creative_edit_bid_creative_error(self):
     data = {
         "customerId": self.customerId,
         "bidding": "{\"bid\":2,\"billingType\":1}"
     }
     creative = ['', '   ', RandomId.get_num(1000, 10000)]
     data.update({"signId": self.signId})
     for i in range(len(creative)):
         data.update({"creativeId": creative[i]})
         url = GenerateURL().generate_url(u=str(self.uri + self.port),
                                          d=data)
         request = Client(url, method=self.method).send_request()
         json = request.json()
         print(json)
         self.assertFalse(json['success'])
Ejemplo n.º 16
0
 def test_creative_test(self):
     data = {
         "customerId": self.customerId,
         "sdate": "2018-08-05",
         "edate": "2018-08-05"
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     print(url)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     print(json)
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
     self.log.debug("response " + str(json['result']))
Ejemplo n.º 17
0
 def test_campaign_list_base_customerId_empty_1(self):
     print("获取广告计划列表customerId未传")
     data = {
         # "customerId": self.customerId,
         "sdate": Time().count_datetime(self.time, self.sub),
         "edate": Time().count_datetime(self.time, self.sub)
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertFalse(json['success'])
     self.assertEqual(str(json['code']), str(20))
     self.assertEqual(str(json['msg']), str('参数错误'))
     self.assertEqual(str(json['desc']), str('customerId参数不能为空'))
Ejemplo n.º 18
0
 def test_campaign_list_base_customerId_empty_3(self):
     print("获取广告计划列表customerId与singId不匹配")
     data = {
         "customerId": '123',
         "sdate": Time().count_datetime(self.time, self.sub),
         "edate": Time().count_datetime(self.time, self.sub)
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertFalse(json['success'])
     self.assertEqual(str(json['code']), str(12))
     self.assertEqual(str(json['msg']), str('错误的sign参数'))
     self.assertEqual(str(json['desc']), str('非法的账户信息'))
Ejemplo n.º 19
0
 def test_campaign_edit_budget_base(self):
     data = {
         "customerId":
         self.customerId,
         "campaignId":
         self.campaignId[RandomId.get_num(m=len(self.campaignId)) - 1],
         "newval":
         "1000"
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
     self.assertEqual(str(data['newval']), str(json['result']))
Ejemplo n.º 20
0
 def test_creative_edit_bid_bid_error(self):
     data = {
         "customerId": self.customerId,
         "creativeId": self.creativeId,
         "bidding": "{\"bid\":200,\"billingType\":1}"
     }
     data.update({"signId": self.signId})
     bid = ['', '0.01', '1000', 't']
     for i in range(len(bid)):
         data.update(
             {'bid': "{\"bid\":" + str(bid[i]) + ",\"billingType\":1}"})
         url = GenerateURL().generate_url(u=str(self.uri + self.port),
                                          d=data)
         request = Client(url, method=self.method).send_request()
         json = request.json()
         print(json)
         self.assertFalse(json['success'])
Ejemplo n.º 21
0
 def test_campaign_edit_budget_newval(self):
     data = {
         "customerId":
         self.customerId,
         "campaignId":
         self.campaignId[RandomId.get_num(m=len(self.campaignId)) - 1],
     }
     data.update({"signId": self.signId})
     n = ('-1', '199', '199.9', '100000000.99', '100000001', '', ' ')
     for k in n:
         data.update({"newval": k})
         url = GenerateURL().generate_url(u=str(self.uri + self.port),
                                          d=data)
         request = Client(url, method=self.method).send_request()
         json = request.json()
         self.assertFalse(json['success'])
         print(json)
Ejemplo n.º 22
0
 def test_campaign_edit_status_base(self):
     self.campaignId = str(self.campaignId).split(',')
     data = {
         "customerId":
         self.customerId,
         "campaignIds":
         self.campaignId[RandomId.get_num(0, len(self.campaignId))],
         # "campaignIds": "100038746",
         "newval":
         "1"
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
Ejemplo n.º 23
0
 def test_group_list_base(self):
     data = {
         "customerId": self.customerId,
         "groupIds": self.groupId1 + ',' + self.groupId2,
         "newval": "2"
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri+self.port), d=data)
     request = Client(url, method=self.method).send_request()
     json = request.json()
     self.assertTrue(json['success'])
     self.assertEqual(0, json['code'])
     for i in range(len(json['result'])):
         if json['result'][i]['id'] == self.groupId1 or json['result'][i]['id'] == self.groupId2:
             if data['newval'] == json['result'][i]['result']:
                 self.assertTrue(True)
         else:
             self.assertFalse(False)
Ejemplo n.º 24
0
 def test_single(self):
     data = {
         "customerId": self.customerId,
         # "customerId": "12",
         # "campaignIds": "100000098,100000711,100001265",
         "kw": "100038745",
         "sdate": "2018-07-16",
         "edate": "2018-07-16"
     }
     data.update({"signId": self.signId})
     url = GenerateURL().generate_url(u=str(self.uri + self.port), d=data)
     request = Client(url, method=self.method).send_request()
     j = request.json()
     # print(j)
     print(j)
     for i in range(len(j['result']['list'])):
         for key, values in j['result']['list'][i].items():
             print(str(key) + ": " + str(values))
         print('\n')
     # print(j['msg'])
     print(j['result']['list'])