def test_returns_empty_if_no_object_of_given_model_is_available(self): r = Related(publishable=self.publishables[0]) r.related = self.publishable r.save() tools.assert_equals([], Related.objects.get_related_for_object( self.publishable, 3, mods=[Related]))
def test_returns_manual_objects_first(self): r = Related(publishable=self.publishable) r.related = self.category r.save() tools.assert_equals( [self.category, self.publishables[-1]], Related.objects.get_related_for_object(self.publishable, 2) )
def test_returns_manual_objects_first(self): r = Related(publishable=self.publishable) r.related = self.category r.save() tools.assert_equals([self.category, self.publishables[-1]], Related.objects.get_related_for_object( self.publishable, 2))
def test_returns_only_manual_objects_when_direct_finder_specified(self): r = Related(publishable=self.publishables[0]) r.related = self.publishable r.save() tools.assert_equals([self.publishables[0].pk], [ p.pk for p in Related.objects.get_related_for_object( self.publishable, 2, finder='directly') ])
def test_returns_unique_objects(self): r = Related(publishable=self.publishable) r.related = self.publishables[-2] r.save() tools.assert_equals( [self.publishables[-2].pk, self.publishables[-1].pk, self.publishables[-3].pk], [p.pk for p in Related.objects.get_related_for_object(self.publishable, 3)], )
def test_returns_only_manual_objects_when_direct_finder_specified(self): r = Related(publishable=self.publishable) r.related = self.publishables[0] r.save() tools.assert_equals( [self.publishables[0].pk], [p.pk for p in Related.objects.get_related_for_object(self.publishable, 2, finder="directly")], )
def test_returns_manual_objects_first(self): r = Related(publishable=self.publishables[0]) r.related = self.publishable r.save() tools.assert_equals( [self.publishables[0].pk, self.publishables[-1].pk], [p.pk for p in Related.objects.get_related_for_object(self.publishable, 2)] )
def test_returns_manual_objects_of_correct_model_type_first(self): r = Related(publishable=self.publishables[0]) r.related = self.publishable r.save() tools.assert_equals( [self.publishables[0].pk, self.publishables[-1].pk], [p.pk for p in Related.objects.get_related_for_object(self.publishable, 2, mods=[self.publishable.__class__])] )
def test_returns_manual_objects_first(self): r = Related(publishable=self.publishables[0]) r.related = self.publishable r.save() tools.assert_equals( [self.publishables[0].pk, self.publishables[-1].pk], [ p.pk for p in Related.objects.get_related_for_object( self.publishable, 2) ])
def test_returns_manual_objects_of_correct_model_type_first(self): r = Related(publishable=self.publishables[0]) r.related = self.publishable r.save() tools.assert_equals( [self.publishables[0].pk, self.publishables[-1].pk], [ p.pk for p in Related.objects.get_related_for_object( self.publishable, 2, mods=[self.publishable.__class__]) ])
def test_returns_unique_objects(self): r = Related(publishable=self.publishables[-2]) r.related = self.publishable r.save() tools.assert_equals([ self.publishables[-2].pk, self.publishables[-1].pk, self.publishables[-3].pk ], [ p.pk for p in Related.objects.get_related_for_object( self.publishable, 3) ])
def test_returns_empty_if_no_object_of_given_model_is_available(self): r = Related(publishable=self.publishables[0]) r.related = self.publishable r.save() tools.assert_equals([], Related.objects.get_related_for_object(self.publishable, 3, mods=[Related]))