Exemplo n.º 1
0
 def test_recommended_items(self):
     calculate_similar_items(RatedItem.objects.all())
     # failure
     result = recommended_items(RatedItem.objects.all(), self.user_g)
     r1, r2, r3 = result
     self.assertEqual(str(r1[0])[:5], '3.610')
     self.assertEqual(r1[1], self.food_a)
     
     self.assertEqual(str(r2[0])[:5], '3.531')
     self.assertEqual(r2[1], self.food_f)
     
     self.assertEqual(str(r3[0])[:5], '2.960')
     self.assertEqual(r3[1], self.food_c)
 
     result = recommended_items(RatedItem.objects.all(), self.user_c)
     r1, r2 = result
     
     self.assertEqual(str(r1[0])[:5], '2.287')
     self.assertEqual(r1[1], self.food_c)
     
     self.assertEqual(str(r2[0])[:5], '2.084')
     self.assertEqual(r2[1], self.food_e)
 def recommended_items(self, user):
     return recommended_items(self.all(), user)
Exemplo n.º 3
0
 def recommended_items(self, user):
     return recommended_items(self.all(), user)