Beispiel #1
0
 def setUp(self):
     target = ForeignKeyTarget(name='target-1')
     target.save()
     new_target = ForeignKeyTarget(name='target-2')
     new_target.save()
     for idx in range(1, 4):
         source = ForeignKeySource(name='source-%d' % idx, target=target)
         source.save()
 def setUp(self):
     target = ForeignKeyTarget(name="target-1")
     target.save()
     new_target = ForeignKeyTarget(name="target-2")
     new_target.save()
     for idx in range(1, 4):
         source = ForeignKeySource(name="source-%d" % idx, target=target)
         source.save()
Beispiel #3
0
 def setUp(self):
     target = ForeignKeyTarget(name='target-1')
     target.save()
     for idx in range(1, 4):
         if idx == 3:
             target = None
         source = NullableForeignKeySource(name='source-%d' % idx, target=target)
         source.save()
    def test_queryset_size_with_Q_limited_choices(self):
        limited_target = ForeignKeyTarget(name="limited-target")
        limited_target.save()

        class QLimitedChoicesSerializer(serializers.ModelSerializer):
            class Meta:
                model = ForeignKeySourceWithQLimitedChoices
                fields = ("id", "target")

        queryset = QLimitedChoicesSerializer().fields["target"].get_queryset()
        assert len(queryset) == 1
    def test_queryset_size_with_Q_limited_choices(self):
        limited_target = ForeignKeyTarget(name="limited-target")
        limited_target.save()

        class QLimitedChoicesSerializer(serializers.ModelSerializer):
            class Meta:
                model = ForeignKeySourceWithQLimitedChoices
                fields = ("id", "target")

        queryset = QLimitedChoicesSerializer().fields["target"].get_queryset()
        assert len(queryset) == 1
    def setUp(self):
        """
        Create 3 BasicModel instances.
        """
        items = ["foo", "bar", "baz"]
        for item in items:
            t = ForeignKeyTarget(name=item)
            t.save()
            ForeignKeySource(name="source_" + item, target=t).save()

        self.objects = ForeignKeySource.objects
        self.data = [{"id": obj.id, "name": obj.name} for obj in self.objects.all()]
        self.view = FKInstanceView.as_view()
Beispiel #7
0
    def setUp(self):
        """
        Create 3 BasicModel instances.
        """
        items = ['foo', 'bar', 'baz']
        for item in items:
            t = ForeignKeyTarget(name=item)
            t.save()
            ForeignKeySource(name='source_' + item, target=t).save()

        self.objects = ForeignKeySource.objects
        self.data = [{
            'id': obj.id,
            'name': obj.name
        } for obj in self.objects.all()]
        self.view = FKInstanceView.as_view()
    def setUp(self):
        """
        Create 3 BasicModel instances.
        """
        items = ['foo', 'bar', 'baz']
        for item in items:
            t = ForeignKeyTarget(name=item)
            t.save()
            ForeignKeySource(name='source_' + item, target=t).save()

        self.objects = ForeignKeySource.objects
        self.data = [
            {'id': obj.id, 'name': obj.name}
            for obj in self.objects.all()
        ]
        self.view = FKInstanceView.as_view()
 def test_queryset_size_with_limited_choices(self):
     limited_target = ForeignKeyTarget(name="limited-target")
     limited_target.save()
     queryset = ForeignKeySourceWithLimitedChoicesSerializer(
     ).fields["target"].get_queryset()
     assert len(queryset) == 1
 def test_queryset_size_with_limited_choices(self):
     limited_target = ForeignKeyTarget(name="limited-target")
     limited_target.save()
     queryset = ForeignKeySourceWithLimitedChoicesSerializer().fields["target"].get_queryset()
     assert len(queryset) == 1