Exemple #1
0
    def test_themedetail_success(self):
        '''所有参数都传'''

        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "select * from mipot_theme where deleted!='1'"
        data_count = cursor.execute(sql)
        print data_count
        if data_count > 0:
            cursor.scroll(0)
            rows = cursor.fetchone()
            print rows
            id = rows['id']
            print id
            self.url_path=self.url_path + str(id)
            params = ''
            r = self.bujiami('GET',
                            self.url_path,
                             params
                            )
            print r
            js = json.loads(r)
            self.assertEqual(js['state'], 1)
            self.assertIn('success', js['message'])
        else:
            print "不存在话题"
 def test_review_pa(self):
     '''只传必填参数都传,发表作品评论或回复评论'''
     token = Login().login()  # 引用登录
     # token = 'YTk2OGZjODJkYTNhMzA1ZGNjODhiMzJjMDhkOGQwMzI='
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT * from mipot_recipe_show_comment"
     data_count = cursor.execute(sql)
     print data_count
     if data_count > 0:
         rows = cursor.fetchone()
         print rows
         showId = rows['recipe_show_id']
         print showId
         params = 'content=test&showId=' + str(showId)
         r = self.myhttp(
             'POST',
             self.url_path,
             params,
             # {'showId': 695, 'content': '好'},
             token)
         print r
         js = json.loads(r)
         print js
         self.assertEqual(js['state'], 1)
         self.assertIn('回复成功', js['message'])
     else:
         print "请先发表作品评论"
Exemple #3
0
 def test_topiccomment_success(self):
     '''所有字段都传,评论成功'''
     token = Login().login()  # 引用登录
     # token = 'ZTI0NTgwNmY0YTljZTcyOTc5ZWFiYTdjYzRkYTNkNGE='
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT A.* from  mipot_topic_comment A,mipot_topic B where A.is_deleted != 1 and B.is_deleted !=1 and A.topic_id =B.id"
     data_count = cursor.execute(sql)
     print data_count
     if data_count > 0:
         rows = cursor.fetchone()
         print rows
         topicId = rows['topic_id']
         parentId = rows['id']
         print topicId
         print parentId
         params = 'content=test&topicId=' + str(
             topicId) + '&parentId=' + str(parentId)
         print params
         r = self.myhttp('POST', self.url_path, params, token)
         print r
         js = json.loads(r)
         print js
         self.assertEqual(js['state'], 1)
         self.assertIn('发表成功', js['message'])
     else:
         print "请先发表话题"
Exemple #4
0
 def test_readpost_success(self):
     '''所有参数都传,阅读成功'''
     token = Login().login()  # 引用登录
     print token
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "select * from mipot_message where username='******'"
     data_count = cursor.execute(sql)
     print data_count
     cursor.scroll(0)
     rows = cursor.fetchone()
     print rows
     mid = rows['id']
     print mid
     if data_count > 0:
         params = 'mid='+str(mid)
         r = self.myhttp('POST',
                         self.url_path,
                         params,
                          token
                          )
         print r
         js = json.loads(r)
         self.assertEqual(js['state'], 1)
         self.assertIn( '操作成功',js['message'])
     else:
         print "不存在消息"
 def test_recipeCommentdelpost_br(self):
     '''所有参数都传,删除别人的评论,删除失败'''
     token = Login().login()  # 引用登录
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "select A.* from mipot_recipe_comment A,mipot_recipe B where A.userid !='1081' and B.state='2200' and A.recipeId=B.id"
     data_count = cursor.execute(sql)
     print data_count
     if data_count > 0:
         cursor.scroll(0)
         rows = cursor.fetchone()
         print rows
         ypcommentid = rows['id']
         print ypcommentid
         params = 'commentId=' + str(ypcommentid)
         r = self.myhttp('POST',
                         self.url_path,
                         params,
                         # {'commentId': ypcommentid},
                         token
                         )
         print r
         js = json.loads(r)
         self.assertEqual(js['state'], -1)
         self.assertIn('删除失败 : 您没有权限删除此评论', js['message'])
     else:
         print '删除失败 : 该评论已经被删除'
Exemple #6
0
    def test_checknew_renew(self):
        '''release_code传入最新的版本代码时,未有新版本'''
        # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "SELECT * from mipot_app_release where state='2200' and platform='1'  ORDER BY id DESC "
        data_count = cursor.execute(sql)
        print data_count
        rows = cursor.fetchone()
        print rows
        release_code = rows['release_code']
        print release_code
        params= 'release_code='+ str(release_code)
        print params
        r = self.myhttp('GET',
                        self.url_path,
                        params,

                        )
        print r
        js = json.loads(r)
        if data_count > 1:
            self.assertEqual(js['state'], -4)
            self.assertIn('未有新版本', js['message'])

        else:
            self.assertEqual(js['state'],1)
            self.assertIn('新版本获取成功', js['message'])
Exemple #7
0
 def test_topicdpost_success(self):
     '''类型为其他,所有参数都传,举报成功'''
     token = Login().login()  # 引用登录
     print token
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "select * from mipot_topic where user_id!='1081' and is_deleted ='0'"
     data_count = cursor.execute(sql)
     print data_count
     cursor.scroll(0)
     rows = cursor.fetchone()
     print rows
     id = rows['id']
     print id
     # params = 'type=15030&content=其他&topicId=' + str(id)
     r = self.topicpost('POST', self.url_path, {
         'type': 15030,
         'content': u'其他',
         'topicId': id
     }, token)
     print r
     js = json.loads(r)
     self.assertEqual(js['state'], 1)
     self.assertIn('举报成功', js['message'])
Exemple #8
0
    def test_reciperesumepoint_success(self):
        '''获取开盖步骤详情'''
        # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "SELECT B.* from mipot_recipe A,mipot_recipe_step B where A.id = B.recipeId \
              and A.state='2200' and B.resumeIndex is NOT NULL"

        data_count = cursor.execute(sql)
        print data_count
        rows = cursor.fetchone()
        print rows
        recipeId = rows['recipeId']
        resumeIndex = rows['resumeIndex']
        print recipeId
        params = 'recipeid=' + str(recipeId) + '&stepIndex=' + str(resumeIndex)
        r = self.myhttp('GET', self.url_path, params
                        # {'recipeid':recipeId, 'stepIndex':resumeIndex},
                        )
        print r
        js = json.loads(r)
        if data_count > 0:
            self.assertEqual(js['state'], 1)
            self.assertIn('获取步骤信息成功', js['message'])

        else:
            print "不存在断点食谱"
Exemple #9
0
    def test_topicthemelist_success(self):
        '''所有参数都传'''
        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "select * from mipot_theme where deleted!='1'"
        data_count = cursor.execute(sql)
        print data_count
        if data_count > 0:
            cursor.scroll(0)
            rows = cursor.fetchone()
            print rows
            themeid = rows['id']
            params = 'pageno=1&perpage=20&themeid='+str(95)
            # params = 'pageno=1&perpage=10&themeid=175'
            print params
            r = self.myhttp('GET',
                            self.url_path,
                             params
                            )
            print r
            js = json.loads(r)
            self.assertEqual(js['state'], 1)
            self.assertIn('获取话题相关主题列表成功', js['message'])
            print "话题下的主题数量:"+str(len(js['result']))
            print "话题参与人数:" + str(js['result'][0]["themes"][0]["participants"])
            for i in range(len(js['result'])):
                print js['result'][i]['content']

        else:
            print "不存在话题"
Exemple #10
0
    def test_articletopadv_zxsuccess(self):
        '''6202自选banner'''
        db = MyDB().getCon()
        # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "SELECT * FROM mipot_article WHERE type = '6202'and state='2200'"
        data_count = cursor.execute(sql)
        print data_count
        rows = cursor.fetchall()
        print rows
        for row in rows:
            print row
        params = 'type=6202'
        r = self.myhttp('GET', self.url_path, params
                        # {'type': '6202'}
                        )
        print r
        js = json.loads(r)
        if data_count > 0:
            self.assertEqual(js['state'], 1)
            self.assertIn('banner数据获取成功', js['message'])
            print row['title']
            print js['result'][0]['title']
            # print js['result'][1]['title']

        else:
            self.assertEqual(js['state'], 0)
            self.assertIn('头部banner没有数据', js['message'])
 def test_test_showcommentdelpost_ysc(self):
     '''删除已删除的评论,提示已删除'''
     token = Login().login()  # 引用登录
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT * from mipot_recipe_show_comment where user_id!='1053'"
     data_count = cursor.execute(sql)
     print data_count
     if data_count > 0:
         rows = cursor.fetchone()
         print rows
         commentId = rows['id']
         showId = rows['recipe_show_id']
         print showId
         params = 'showId=' + str(showId) + '&commentId=' + str(commentId)
         r = self.myhttp(
             'POST',
             self.url_path,
             params,
             # {'showId': showId, 'commentId': commentId},
             token)
         print r
         js = json.loads(r)
         self.assertEqual(js['state'], -1)
         self.assertIn('删除失败', js['message'])
     else:
         print "不存在评论"
Exemple #12
0
 def test_stepinfoget_success(self):
     '''获取食谱步骤成功'''
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT A.* from mipot_recipe A,mipot_recipe_step B where A.id = B.recipeId \
           and A.state='2200' and B.resumeIndex is NOT NULL"
     data_count = cursor.execute(sql)
     print data_count
     cursor.scroll(0)
     rows = cursor.fetchone()
     print rows
     recipeid = rows['id']
     print recipeid
     if data_count>0:
         params = 'recipeid='+str(recipeid)
         r = self.myhttp('GET',
                     self.url_path,
                     params,
                     # {'recipeid': recipeid}
                     )
         print r
         print '返回结果:'+ r
         js = json.loads(r)
         self.assertEqual(js['state'], 1)
         self.assertIn('获取食谱步骤成功',js['message'])
     else:
         print '不存在食谱'
 def test_collectdeviceget_plose(self):
     '''pageNo未传'''
     token = Login().login()  # 引用登录
     print token
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT * from mipot_device_useinfo where userId='54644930'"
     data_count = cursor.execute(sql)
     print data_count
     rows = cursor.fetchone()
     print rows
     deviceId = rows['deviceId']
     print deviceId
     params = 'deviceId=' + str(deviceId)
     r = self.myhttp(
         'GET',
         self.url_path,
         params,
         # { 'deviceId':deviceId},
         token)
     print r
     if data_count > 0:
         js = json.loads(r)
         self.assertEqual(js['state'], 1)
         self.assertIn('获取菜谱列表成功', js['message'])
     else:
         print "不存在收藏食谱"
 def test_showall_btsuccess(self):
     '''必填字段传入正确,获取成功'''
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT * from mipot_recipe_show"
     data_count = cursor.execute(sql)
     print data_count
     if data_count > 0:
         rows = cursor.fetchone()
         print rows
         recipeId = rows['recipe_id']
         params = 'curPage=1&recipeId=' + str(recipeId)
         r = self.myhttp(
             'GET',
             self.url_path,
             params,
             # {'recipeId': recipeId, 'curPage': '1'},
         )
         print r
         js = json.loads(r)
         self.assertEqual(js['state'], 1)
         self.assertIn('获取成功', js['message'])
     else:
         print "未找到作品"
Exemple #15
0
 def test_cookscriptget_sysuccess(self):
     '''所有参数都传'''
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT recipe_cooktemplet_id,dmg_id  FROM mipot_recipe_cook_templet_script " \
           "WHERE recipe_cooktemplet_id IN (SELECT id FROM mipot_recipe_cook_templet WHERE state = 2200) "
     data_count = cursor.execute(sql)
     print data_count
     rows = cursor.fetchone()
     print rows
     templetid = rows['recipe_cooktemplet_id']
     dmgid = rows['dmg_id']
     # params={'templetid':templetid,'deviceid':dmgid}
     params = 'templetid=' + str(10) + '&deviceid=' + str(45423531)
     print params
     r = self.myhttp(
         'GET',
         self.url_path,
         params,
     )
     print r
     js = json.loads(r)
     self.assertEqual(js['state'], 1)
     self.assertIn("get recipecooktempletscript success", js['message'])
Exemple #16
0
    def test_topiccommentdeletes_htys(self):
        '''话题已经被发布者删除,用户1053'''
        token = Login().login()  # 引用登录
        # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "SELECT B.* from  mipot_topic A,mipot_topic_comment B \
               where A.id=B.topic_id and A.is_deleted =1 and B.user_id='1081' and B.is_deleted != 1"

        data_count = cursor.execute(sql)
        print data_count
        if data_count > 0:
            rows = cursor.fetchone()
            print rows
            commentId = rows['id']
            print commentId
            params = 'commentId=' + str(commentId)
            r = self.myhttp('POST', self.url_path, params, token)
            print r
            js = json.loads(r)
            print js
            self.assertEqual(js['state'], -1)
            self.assertIn('该评论已经被删除', js['message'])
        else:
            print "话题已被删除"
    def test_literecipeget_btsuccess(self):
        '''只传必填参数,操作成功'''
        # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "select B.deviceId from mipot_device B ,mipot_device_model_recipe A where  \
              A.devicemodelid=B.deviceModelId and B.deviceModelId = '1'"

        data_count = cursor.execute(sql)
        print data_count
        if data_count > 0:
            rows = cursor.fetchone()
            print rows
            deviceid = rows['deviceId']
            params = 'deviceid=' + str(deviceid)
            r = self.myhttp(
                'GET',
                self.url_path,
                params,
            )
            print r
            js = json.loads(r)
            print js
            self.assertEqual(js['state'], 1)
            self.assertIn('获取食谱列表成功', js['message'])
        else:
            print "未找到默认食谱"
Exemple #18
0
 def test_showreport_btsuccess(self):
     ''' 类型不为其他,只传必填参数举报成功'''
     token = Login().login()  # 引用登录
     print token
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT * from mipot_recipe_show"
     data_count = cursor.execute(sql)
     print data_count
     cursor.scroll(0)
     rows = cursor.fetchone()
     print rows
     showId = rows['id']
     print showId
     params = 'type=15000&showId=' + str(showId)
     r = self.myhttp(
         'POST',
         self.url_path,
         params,
         # {'type': 15000,  'showId': showId},
         token)
     print r
     js = json.loads(r)
     self.assertEqual(js['state'], 1)
     self.assertIn('举报作品成功', js['message'])
Exemple #19
0
    def test_topicthemelist_btsuccess(self):
        '''只传必填参数'''

        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "select * from mipot_theme where deleted!='1'"
        data_count = cursor.execute(sql)
        print data_count
        if data_count > 0:
            cursor.scroll(0)
            rows = cursor.fetchone()
            print rows
            themeid = rows['id']
            params = 'themeid=' + str(themeid)
            print params
            r = self.myhttp('GET', self.url_path, params)
            print r
            js = json.loads(r)
            self.assertEqual(js['state'], 1)
            self.assertIn('获取话题相关主题列表成功', js['message'])
            print len(js['result'])
            for i in range(len(js['result'])):
                print js['result'][i]['content']
        else:
            print "不存在话题"
    def test_praise_weiz(self):
        '''未赞时,操作类型为:cancelPraise,还没有赞过'''
        token = Login().login()  # 引用登录
        # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "select * from mipot_topic where id not in (select mipot_topic.id from mipot_topic,mipot_topic_praise \
                where mipot_topic.id=mipot_topic_praise.topic_id and \
                mipot_topic.is_deleted='0' and mipot_topic_praise.user_id='1081') and \
                is_deleted='0'"

        data_count = cursor.execute(sql)
        print data_count
        if data_count > 0:
            rows = cursor.fetchone()
            print rows
            topicId = rows['id']
            print topicId
            params = 'praise=cancelPraise&topicId=' + str(topicId)
            r = self.myhttp('POST', self.url_path, params, token)
            print r
            js = json.loads(r)
            print js
            self.assertEqual(js['state'], -1)
            self.assertIn('还没有赞过', js['message'])
        else:
            print "请先点赞"
 def test_v3addpost_success(self):
     '''收藏成功'''
     token = Login().login()  # 引用登录
     print token
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT * from mipot_recipe A where A.state='2200'"
     data_count = cursor.execute(sql)
     print data_count
     rows = cursor.fetchone()
     print rows
     recipeId = rows['id']
     print recipeId
     params = 'recipeId=' + str(recipeId)
     r = self.myhttp('POST',
                     self.url_path,
                     params,
                      # {'recipeId': recipeId},#1957
                      token
                      )
     print r
     js = json.loads(r)
     self.assertEqual(js['state'], 1)
     self.assertIn( '收藏成功',js['message'])
    def test_showinformationget_ypbr(self):
        ''' 存在评论记录,发布者查看详情,查看到评论列表'''
        token = Login().login()  # 引用登录
        # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "SELECT * from mipot_recipe_show where  praise_count =0 and  \
              user_id='1081' and id in (select recipe_show_id from mipot_recipe_show_comment)"
        data_count = cursor.execute(sql)
        print data_count
        if data_count > 0:
            rows = cursor.fetchone()
            print rows
            showId = rows['id']
            print showId
            params = 'showId=' + str(showId)
            r = self.myhttp('GET',
                             self.url_path,
                             params,
                             # {'showId': showId},
                             token
                             )
            print r
            js = json.loads(r)
            self.assertEqual(js['state'], 1)
            self.assertIn('获取成功', js['message'])
            self.assertEqual(False, js['result'][0]['praised'])
            self.assertEqual(0, js['result'][0]['showing']['praiseCount'])
            self.assertIsNot(0, js['result'][0]['commentSize'])

        else:
            print "不存在对应作品记录"
 def test_unreg_success(self):
     '''解绑饭煲(主动解除分享给别人的设备)'''
     token = Login().login()  # 引用登录
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT * from mipot_device_useinfo where userId != '54644930'"
     data_count = cursor.execute(sql)
     print data_count
     if data_count > 0:
         rows = cursor.fetchone()
         print rows
         deviceId = rows['deviceId']
         toUserId = rows['userId']
         print deviceId
         print toUserId
         params = 'deviceId=' + str(deviceId) + '&toUserId=' + str(toUserId)
         r = self.myhttp(
             'POST',
             self.url_path,
             params,
             # {'deviceId':deviceId,'toUserId':toUserId},
             token)
         print r
         js = json.loads(r)
         print js
         self.assertEqual(js['state'], 1)
         self.assertIn('操作成功', js['message'])
     else:
         print "不存在分享设备"
    def test_showinformationget_tokenno(self):
        '''token不传'''
        # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "SELECT * from mipot_recipe_show where id in (select recipe_show_id from mipot_recipe_show_praise)"
        data_count = cursor.execute(sql)
        print data_count
        if data_count > 0:
            rows = cursor.fetchone()
            print rows
            showId = rows['id']
            praisecount = rows['praise_count']
            print showId
            print praisecount
            params = 'showId=' + str(showId)
            r = self.myhttp('GET',
                             self.url_path,
                            params,
                             # {'showId': showId},

                             )
            print r
            js = json.loads(r)
            self.assertEqual(js['state'], 1)
            self.assertIn('获取成功', js['message'])
            self.assertEqual(False, js['result'][0]['praised'])
            self.assertEqual(praisecount, js['result'][0]['showing']['praiseCount'])

        else:
            print "不存在对应作品记录"
Exemple #25
0
 def test_topicdpost_br(self):
     '''删除别人的主题,删除失败'''
     token = Login().login()  # 引用登录
     print token
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "select * from mipot_topic where user_id!='1081'and is_deleted ='0'"
     data_count = cursor.execute(sql)
     print data_count
     cursor.scroll(0)
     rows = cursor.fetchone()
     print rows
     id = rows['id']
     print id
     params = 'topicId=' + str(id)
     r = self.myhttp('POST',
                     self.url_path,
                     params,
                     token
                     )
     print r
     js = json.loads(r)
     self.assertEqual(js['state'], -1)
     self.assertIn('删除话题失败',js['message'])
 def test_cpraise_nozan(self):
     '''未点赞过的作品进行点赞'''
     token = Login().login()  # 引用登录
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "select * from mipot_recipe_show where id not in(select A.id from mipot_recipe_show A,mipot_recipe_show_praise B  \
            where a.id =b.recipe_show_id and b.user_id='1081')"
     data_count = cursor.execute(sql)
     print data_count
     if data_count > 0:
         rows = cursor.fetchone()
         print rows
         showId = rows['id']
         print showId
         params = 'showId=' + str(showId)
         r = self.myhttp('GET',
                          self.url_path,
                          params,
                          token
                          )
         print r
         js = json.loads(r)
         self.assertEqual(js['state'], 1)
         self.assertIn('取消点赞成功', js['message'])
     else:
         print "不存在未点赞记录"
 def test_topiccomment_btsuccess(self):
     '''只传必填字段,评论成功'''
     token = Login().login()  # 引用登录
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "SELECT A.* from  mipot_topic_comment A,mipot_topic B where A.is_deleted != 1 and B.is_deleted !=1 and A.topic_id =B.id "
     data_count = cursor.execute(sql)
     print data_count
     if data_count > 0:
         rows = cursor.fetchone()
         print rows
         topicId = rows['topic_id']
         print topicId
         params = 'content=test&topicId=' + str(topicId)
         r = self.myhttp(
             'POST',
             self.url_path,
             params,
             # {'topicId': topicId, 'content': 'test'},
             token)
         print r
         js = json.loads(r)
         print js
         self.assertEqual(js['state'], 1)
         self.assertIn('发表成功', js['message'])
     else:
         print "请先发表话题"
    def test_themedetail_noncerror(self):
        '''nonce不正确'''
        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "select * from mipot_theme"
        data_count = cursor.execute(sql)
        print data_count
        cursor.scroll(0)
        rows = cursor.fetchone()
        print rows
        id = rows['id']
        print id
        params = {'': ''}
        r = self.noncerror('GET', self.url_path + str(id), params)

        print r
Exemple #29
0
 def test_recipehintget_success(self):
     '''所有参数都传'''
     # db = MySQLdb.connect("192.168.1.64", "root", "123456", "new_independent_api")  # 打开数据库连接
     db = MyDB().getCon()
     cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
     sql = "select * from mipot_device where deviceModelId='1'"
     data_count = cursor.execute(sql)
     print data_count
     cursor.scroll(0)
     rows = cursor.fetchone()
     print rows
     deviceid = rows['deviceId']
     print deviceid
     params = 'content=饭&deviceid=' + str(deviceid)
     r = self.myhttp('GET', self.url_path, params)
     print r
     js = json.loads(r)
     self.assertEqual(js['state'], 1)
    def test_showdetail_success(self):
        '''所有参数都传'''

        db = MyDB().getCon()
        cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        sql = "select * from mipot_recipe_show"
        data_count = cursor.execute(sql)
        print data_count
        if data_count > 0:
            cursor.scroll(0)
            rows = cursor.fetchone()
            print rows
            id = rows['id']
            print id
            self.url_path = self.url_path + str(id)
            params = ''
            r = self.nosign('GET',
                             self.url_path,
                             params
                             )
            print r