Пример #1
0
    def test_case3(self):
        '''eid为空时,发布会发布失败'''

        f = get_txt()
        self.data = {}

        self.data['name'] = f.get_name() + '电影发布会'
        self.data['status'] = f.get_num(0, 1)
        self.data['limit'] = f.get_num(20, 200)
        self.data['address'] = f.get_address()
        self.data['start_time'] = f.get_datetime()
        r = requests.post(self.u, self.data)
        self.res = r.json()
        print(self.res)
        g.con_mysql()

        sql = 'select * from sign_event where name="%s";'
        select_result = g.execute_sql(sql % (self.data['name']))

        try:
            self.assertTrue('parameter error', 'massage')
            self.assertEqual(0, select_result)
            self.assertTrue(10021, 'status')

        except:
            print('Fail')
            raise Exception
Пример #2
0
    def test_case2(self):
        '''成功发布一条发布会'''

        f = get_txt()
        self.data = {}
        self.data['eid'] = f.get_num(1, 100)
        self.data['name'] = f.get_name() + '电影发布会'
        self.data['status'] = f.get_num(0, 1)
        self.data['limit'] = f.get_num(20, 200)
        self.data['address'] = f.get_address()
        self.data['start_time'] = f.get_datetime()
        r = requests.post(self.u, self.data)
        self.res = r.json()
        print(self.res)
        g.con_mysql()

        sql = 'select * from sign_event where id="%d" and name="%s";'
        select_result = g.execute_sql(sql %
                                      (self.data['eid'], self.data['name']))

        try:
            self.assertTrue('add event success', 'massage')
            self.assertEqual(1, select_result)
            self.assertTrue(10000, 'status')

        except:
            print('Fail')
            raise Exception
Пример #3
0
    def test_case3(self):
        '''成功添加一名手机号第二位为3的嘉宾'''

        f=get_txt()
        self.data={}
        self.data['eid']=1011
        self.data['realname']=f.get_name()
        self.data['phone']=f.get_phone('13')
        self.data['email']=f.get_email()
        r=requests.post(self.u,self.data)
        self.res=r.json()
        print(self.res)
        g.con_mysql()
        sql='select * from sign_guest where phone="%s" and realname="%s";'
        select_result=g.execute_sql(sql %(self.data['phone'],self.data['realname']))

        self.assertTrue('add guest success','massage')
        self.assertEqual(1,select_result)
        self.assertTrue(10000, 'status')
Пример #4
0
    def test_case6(self):
        '''添加一位手机号为12的手机号添加嘉宾失败'''

        f = get_txt()
        self.data = {}
        self.data['eid'] = 1011
        self.data['realname'] = f.get_name()
        self.data['phone'] = f.get_phone('151')
        self.data['email'] = f.get_email()
        r = requests.post(self.u, self.data)
        self.res = r.json()
        print(self.res)

        g.con_mysql()
        sql = 'select * from sign_guest where phone="%s" and realname="%s";'
        select_result = g.execute_sql(sql % (self.data['phone'], self.data['realname']))

        self.assertTrue('phone error', 'massage')
        self.assertEqual(0, select_result)
        self.assertTrue(10027, 'status')
Пример #5
0
 def test_case2(self):
     '''name为空时,发布会发布失败'''
     self.url='http://127.0.0.1:8000/api/add_event/'
     f = get_txt()
     self.data={}
     self.data['eid']=f.get_num(0,100)
     self.data['name']=''
     self.data['status']=f.get_num(0,1)
     self.data['limit']=f.get_num(20,200)
     self.data['address']=f.get_address()
     self.data['start_time']=f.get_datetime()
     r=requests.post(self.url,self.data)
     self.res=r.json()
     print(self.res)
     g.con_mysql()
     sql='select * from sign_event where id="%d" and name="%s";'
     select_result=g.execute_sql(sql %(self.data['eid'],self.data['name']))
     print(select_result)
     if self.res['message']=='parameter error' and self.res['status']==10021 and select_result==0:
         print('pass')
     else:
         print('Fail')
Пример #6
0
    def test1(self):
        url='http://127.0.0.1:8000/api/add_event/'
        f=get_txt()
        data={}
        data['eid']=f.get_num(1,100)
        data['name']=f.get_name()
        data['status']=f.get_num(0,1)
        data['limit']=f.get_num(20,200)
        data['address']=f.get_address()
        data['start_time']=f.get_datetime()
        r=requests.post(url,data)
        res=r.json()
        print(res)


        g.con_mysql()
        sql='select * from sign_event where id="%d" and name="%s";'
        select_result=g.execute_sql(sql %(data['eid'],data['name']))

        if res['message']=='add event success' and res['status']==10000 and select_result==1:
            print('pass')
        else:
            print('Fail')