Example #1
0
 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]))
Example #2
0
    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)
        )
Example #3
0
    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))
Example #4
0
    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')
        ])
Example #5
0
    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)],
        )
Example #6
0
    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")],
        )
Example #7
0
    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)]
            )
Example #8
0
    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__])]
            )
Example #9
0
    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)
            ])
Example #10
0
    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__])
            ])
Example #11
0
    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)
        ])
Example #12
0
 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]))