예제 #1
0
 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 "未找到作品"
예제 #2
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'])
예제 #3
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 "不存在消息"
예제 #4
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 "请先发表话题"
예제 #5
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'])
예제 #6
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)