Пример #1
0
 def test01_recharges_create(self):
     """提交充值请求: 接口校验不完善,account应该与登录帐户保持一致"""
     url = self.post_url
     header = self.header
     user = self.user
     self.random = random_char.RandomChar()
     num = self.random.random_char([], 20, 2)  # 生成20位长度混合字符串
     money = int(self.random.random_char([], 3, 0))  # 生成3位长度数字
     t = self.random.localtime()  # 格式化生成当前时间戳
     n = random.randint(0, 2)  # 随机付款方式
     data = {
         "partner": "%s" % user,
         "num": "%s" % num,
         "money": money,
         "time": "%s" % t,
         "method": n,
         "contact": "*****@*****.**"
     }
     r = requests.post(url, data=json.dumps(data), headers=header)
     print(r.text)
     self.assertEqual(r.status_code, 201)
     if r.json()['total'] == 1:
         print(
             '用户:%s,提交充值:%s的申请' %
             (r.json()['data'][0]['partner'], r.json()['data'][0]['money']))
     else:
         print('添加错误数据')
Пример #2
0
    def common_add_users(self):
        """添加初始用户方法。与前端添加用户一致数据。"""
        url = self.post_url
        header = self.header
        self.random = random_char.RandomChar()
        n = self.random.random_char([], 4, 2)  # 生成4位长度混合字符串
        data = {
            "account": "user_%s" % n,
            "password": "******",
            "role": 0,
            "activated": bool(1),
            "company": {
                "name": "qx",
                "address": {
                    "province": "浙江",
                    "city": "杭州市",
                    "district": "西湖区",
                    "remark": "公司地址测试:%s" % n
                }
            }
        }
        r = requests.post(url, data=json.dumps(data), headers=header)
        self.assertEqual(r.status_code, 201)
        if r.json()['total'] == 1:
            print('成功添加一个初始用户:%s' % r.json()['data'][0]['account'])
        else:
            print('添加用户为空')

        return r
Пример #3
0
    def test05_feedbacks_create(self):
        """添加反馈内容正好500字符(此限制只在前端,后端无字数限制)"""
        url=self.post_url
        header = self.header
        self.random=random_char.RandomChar()
        qq=self.random.random_char([],10,1)   # 生成10位长度数字
        data={
            "text": """明还合小该点下见照组字小组按、随按、与个与与模的出还可与用串串定说工该提数提位机该用工出个指数出度小
长数。个串式要点度明符生各说字数。用种字度模式、的应个种个指用应小成具可串机符数该数点数常数常生下机
定数出的求整数长位位的见指成应提随出可定的符整的指数工。常生用指定随机具提数说点位、小个说各见可按个
定数随字位长与明符可具工生与按随长度明要符围字模可说字围定生随数机给随指可随字位还整位随围数说合个、
该还长生。的可说可见用字成与提可了明数合各模位还与方各的的符机成可具成还与户具可范说提数点度还的户数
照说生随符说指、还范机、机的明字。方还用机照数定的点生种机生户户数可小。数提可模、的具字出种长成个度
的成符种用成明户数符数用按见出应模模说、小工指数符可字小户字提符生提给生范度数的数合指度给。位等成按
等组该随数长数具定出数说要应符数字围种还式整机定定围见的随、、字出等下还随位数见种工随要数可出定户指
要的种用生具生还。的的求位与该工指度模随字还符,可生小该与常数组字数定的各定还。给户还机数符字的数机
等。符数具工了符式位各、各指、整数的长、组数数指常生数与成数位组范点可求机说下定符说点成按数围数字照""",
            "type": 2,     # 0=建议,1=问题,2=其它
            "contact": "*****@*****.**"%qq,
            "origin": "PC"
        }
        r = requests.post(url, data=json.dumps(data), headers=header)
        self.assertEqual(r.status_code,201)
        if r.json()['total']==1:
            print('成功添加用户其它反馈id:%s'%r.json()['data'][0]['id'])
        else:
            print('添加错误数据')
Пример #4
0
 def test01_versions_create(self):
     """添加最新版本记录"""
     url = self.post_url
     header = self.header
     self.random = random_char.RandomChar()
     ver = self.random.random_char([], 4, 2)  # 生成4位长度混合字符串
     version = "version.%s" % ver
     md5 = self.random.hash(version)
     n = self.random.random_char([], 4, 0)  # 生成3位长度数字
     t = self.random.localtime()  # 格式化生成当前时间戳
     data = {
         "version": "%s" % version,
         "platform": "windows",
         "size": int(n),
         "level": 0,
         "md5": "%s" % md5,
         "url": "http://test.robot-qixing.com:1014",
         "description": "普通升级_%s" % ver,
         "release_at": "%s" % t
     }
     r = requests.post(url, data=json.dumps(data), headers=header)
     print(r.text)
     self.assertEqual(r.status_code, 201)
     if r.json()['total'] == 1:
         print('成功发布版本记录id:%s' % r.json()['data']['id'])
     else:
         print('添加错误数据')
Пример #5
0
 def test01_post_request(self):
     """上传下载请求"""
     url=self.post_url
     header = self.header
     self.random=random_char.RandomChar()
     name=self.random.random_char([],4,2)   # 生成4位长度混合字符串
     email=self.random.random_char([],8,0)  # 生成6位长度的纯数字字符串
     data={
         "name": "Test-%s"%name,
         "email": "*****@*****.**"%email,
         "phone": "138%s"%email
     }
     #将data序列化为json格式数据,传递给data参数
     r = requests.post(url, data=json.dumps(data), headers=header)
     self.assertEqual(r.status_code,201)
     print('成功上传一个下载请求:\n%s'%r.text)
Пример #6
0
 def test11_modify_info(self):
     """修改登录帐户个人信息:帐户余额"""
     self.t = get_token.GetToken()
     id = self.t.test_userid()
     url = self.post_url + '/%s' % id
     header = self.header
     self.random = random_char.RandomChar()
     n1 = int(self.random.random_char([], 4, 0))  # 生成4位长度的纯数字字符串
     data = {"wallet": {"balance": n1}}
     r = requests.patch(url, data=json.dumps(data), headers=header)
     self.assertEqual(r.status_code, 202)
     n = r.json()['data'][0]['wallet']['balance']
     if n == n1:
         print('当前帐户余额更新为:%s' % n)
     else:
         print('帐户余额修改失败')
Пример #7
0
 def test10_modify_info(self):
     """修改登录帐户个人信息:邮箱地址"""
     self.t = get_token.GetToken()
     self.random = random_char.RandomChar()
     id = self.t.test_userid()
     url = self.post_url + '/%s' % id
     header = self.header
     n1 = self.random.random_char([], 11, 0)  # 生成11位长度的纯数字字符串
     data = {"email": "*****@*****.**" % n1}
     r = requests.patch(url, data=json.dumps(data), headers=header)
     self.assertEqual(r.status_code, 202)
     email1 = r.json()['data'][0]['email']
     email2 = "*****@*****.**" % n1
     if email1 == email2:
         print('email字段修改成功为:%s' % email1)
     else:
         print('email字段修改失败。')
Пример #8
0
 def test01_add_users(self):
     """添加新用户:管理员帐号/激活"""
     url = self.post_url
     header = self.header
     self.random = random_char.RandomChar()
     n = self.random.random_char([], 4, 2)  # 生成4位长度混合字符串
     n1 = self.random.random_char([], 6, 0)  # 生成6位长度的纯数字字符串
     n2 = self.random.random_char([], 2, 0)  # 生成2位长度的纯数字字符串
     data = {
         "account": "admin_%s" % n,
         "nickname": "nick_%s" % n,
         "password": "******",
         "avatar": "",
         "role": 0,
         "activated": bool(1),
         "name": "zz",
         "sex": 1,
         "phone": "13825%s" % n1,
         "email": "*****@*****.**" % n1,
         "company": {
             "name": "qx",
             "job_num": "%s" % n2,
             "job": "server developer",
             "address": {
                 "province": "浙江",
                 "city": "杭州市",
                 "district": "西湖区",
                 "remark": "公司地址测试:%s" % n
             }
         },
         "address": {
             "province": "北京",
             "city": "北京市",
             "district": "朝阳区",
             "remark": "个人地址测试_%s" % n
         }
     }
     #将data序列化为json格式数据,传递给data参数
     r = requests.post(url, data=json.dumps(data), headers=header)
     print(r.text)
     self.assertEqual(r.status_code, 201)
     if r.json()['total'] == 1:
         self.addusers.append(r.json()['data'][0]['id'])
Пример #9
0
 def test19_modify_pwd(self):
     """成功修改个人帐号密码,并将新密码更新config.txt文件。"""
     self.t = get_token.GetToken()
     id = self.t.test_userid()
     url = self.post_url + '/pwd/set/%s' % id
     header = self.header
     self.rt = readconfig.ReadConfig()
     pw = self.rt.get_pw()  #读取当前config文件中的pw值
     opw = pw
     self.random = random_char.RandomChar()
     npw = self.random.random_char([], 6, 2)  # 重新生成6位长度混合字符串
     data = {"old_password": "******" % opw, "new_password": "******" % npw}
     r = requests.post(url, data=json.dumps(data), headers=header)
     self.assertEqual(r.status_code, 200)
     print('当前帐户id:%s,密码更新为:%s' % (id, npw))
     obj = writeconfig.rwconfig()
     path = r"C:\Users\test\AppData\Local\Programs\Python\Python36\autotest\test_api\config.txt"
     obj.modifyconfig(path, 'base', 'pw', str(npw))
     print('更新config.txt文件:[base]--pw值:%s' % npw)
Пример #10
0
 def test03_feedbacks_create(self):
     """添加用户其它反馈:纯文本"""
     url=self.post_url
     header = self.header
     self.random=random_char.RandomChar()
     text=self.random.random_char([],10,2)   # 生成10位长度混合字符串
     qq=self.random.random_char([],10,1)   # 生成10位长度数字
     data={
         "text": "用户其它反馈%s"%text,
         "type": 2,     # 0=建议,1=问题,2=其它
         "contact": "*****@*****.**"%qq,
         "origin": "PC"
     }
     r = requests.post(url, data=json.dumps(data), headers=header)
     self.assertEqual(r.status_code,201)
     if r.json()['total']==1:
         print('成功添加用户其它反馈id:%s'%r.json()['data'][0]['id'])
     else:
         print('添加错误数据')
Пример #11
0
    def test04_feedbacks_create(self):
        """添加反馈内容含有换行,空格等多字符组成"""
        url=self.post_url
        header = self.header
        self.random=random_char.RandomChar()
        qq=self.random.random_char([],10,1)   # 生成10位长度数字
        data={
            "text": """  空格4个字符    然后换行
-------换行-------------------------------
添加多种字符~!@#¥%……&*()——+、】【‘;/.,
再添加字符`1!@#$%^&*()_+\][{}|';:"/.,<>?
123456789""",
            "type": 2,     # 0=建议,1=问题,2=其它
            "contact": "*****@*****.**"%qq,
            "origin": "PC"
        }
        r = requests.post(url, data=json.dumps(data), headers=header)
        self.assertEqual(r.status_code,201)
        if r.json()['total']==1:
            print('成功添加用户其它反馈id:%s'%r.json()['data'][0]['id'])
        else:
            print('添加错误数据')