def test_score_personal_3(self): print_test_info() reco = Reco( test_data['test_score_personal_3']['input']['extracted_data'], True, external_data={ 'item_data': test_item_data, 'user_click': test_data['test_score_personal_3']['input']['user_click'] }) recoList = reco.get_reco_list() expectedList = test_data['test_score_personal_3']['output'] for category in expectedList: for row in expectedList[category]: self.assertTrue( row['reco_hashkey'] in [data['reco_hashkey'] for data in recoList[category]]) recoItem = None for recoItem in recoList[category]: if row['reco_hashkey'] == recoItem['reco_hashkey']: break self.assertTrue(recoItem is not None) for i in range(0, len(row['score'])): if row['score'][i] == -1: continue self.assertEqual( row['score'][i], int((recoItem['score'] % math.pow(10, 6 - i)) / math.pow(10, 5 - i))) self.assertEqual(len(expectedList[category]), len(recoList[category]))
def test_region_filter_5(self): print_test_info() reco = Reco(test_data['test_region_filter_5']['input'], True, external_data={ 'item_data': test_item_data, 'user_click': None }) recoList = reco.get_reco_list() expectedList = test_data['test_region_filter_5']['output'] 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]))