def test_index_packs(self): bot_list = {"response":{"status":{}, "data":{ "bots":[{"id":10,"botname":"mybot"}] }}} responses.add(responses.GET, url="https://news.kae.re/api/0.1.json", body=json.dumps(bot_list),match_querystring=True,status=200) responses.add(responses.GET, url="https://news.kae.re/api/0.1/bots/10.json", body=Data.bot_info,match_querystring=True,status=200) tasks.index_packs() fpack = db.session.query(File_Pack).filter(File_Pack.id == 1).scalar() self.assertEqual(fpack.bot_name,"mybot")
def test_index_bad_json(self): bot_list = {"response":{"status":{}, "data":{ "bots":[{"id":203,"botname":"Tsukuyomi"}] }}} bot_info = """ {"response":{"status":{"code":200,"message":"success","version":0.1},"data":{"bot":{"id":203,"botname":"Tsukuyomi","failedwhois":0,"failedgets":0,"visible":true,"totalpacks":1920,"wait":360,"waited":109,"lastpack":{"id":"1920","gets":"1","size":"14M","name":"[タO2, Ryuki Yumi] COWCOW.rar"},"packlist":null}}}} """ responses.add(responses.GET, url="https://news.kae.re/api/0.1.json", body=json.dumps(bot_list),match_querystring=True,status=200) responses.add(responses.GET, url="https://news.kae.re/api/0.1/bots/203.json", body=bot_info,match_querystring=True,status=200) tasks.index_packs()