def test_recommendations(self): p = UserProfile.objects.in_bulk([1,2,3,4]) self.assertEqual( [], [v.pk for score,v in recommended_venues(p[1])], ) self.assertEqual( [2], [v.pk for score,v in recommended_venues(p[2])], ) self.assertEqual( [], [v.pk for score,v in recommended_venues(p[3])], ) self.assertEqual( set([2, 3]), set([v.pk for score,v in recommended_venues(p[4])]), )
def get_context_data(self): venue_a, venue_b = self.request.user.get_profile().venue_pair() #TODO Move this out of the request cycle! recommendations = recommended_venues(self.request.user.get_profile()) return { 'venue_a': venue_a, 'venue_b': venue_b, 'recommendations': recommendations, }