def save_all_recommend_item(): reco = Reco(json_data, show_external_data=False) all_list = reco.get_all_list() print(json.dumps(all_list, indent=4, sort_keys=True, ensure_ascii=False)) with open('testItemData.json', 'w') as outfile: json.dump(all_list, outfile, indent=4) with open('testItemDataEncoded.json', 'w') as outfile: json.dump(all_list, outfile, indent=4, ensure_ascii=False)
def test_load_all_null(self): print_test_info() reco = Reco(test_data['test_load_all_null']['input'], '', external_data={ 'item_data': test_item_data, 'user_click': None }) recoList = reco.get_all_list() expectedList = test_item_data for category in expectedList: for row in expectedList[category]: self.assertTrue( row['reco_hashkey'] in [data['reco_hashkey'] for data in recoList[category]]) self.assertEqual(len(expectedList[category]), len(recoList[category]))