Skip to content

Commit

Permalink
Merge pull request #959 from Incred/fix-warnings
Browse files Browse the repository at this point in the history
Fix test warnings
  • Loading branch information
tfranzel authored Mar 12, 2023
2 parents 06a39ad + 3f8ed7f commit 3f83a0d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3039,31 +3039,31 @@ class XViewset(viewsets.ModelViewSet):


def test_serializer_foreign_key_default_value_handling(no_warnings):
class M10(models.Model):
class M12(models.Model):
field = models.CharField(unique=True)

class M11(models.Model):
field_related = models.ForeignKey(M10, on_delete=models.CASCADE, default=1)
class M13(models.Model):
field_related = models.ForeignKey(M12, on_delete=models.CASCADE, default=1)

class XSerializer(serializers.ModelSerializer):
field_related = serializers.PrimaryKeyRelatedField(
queryset=M11.objects.all(),
queryset=M13.objects.all(),
default=1,
)
field_related_slug = serializers.SlugRelatedField(
source='field_related',
slug_field='field',
queryset=M10.objects.all(),
queryset=M12.objects.all(),
default='foo',
)

class Meta:
fields = '__all__'
model = M11
model = M13

class XViewset(viewsets.ModelViewSet):
serializer_class = XSerializer
queryset = M11.objects.none()
queryset = M13.objects.none()

schema = generate_schema('/x', XViewset)
assert schema['components']['schemas']['X']['properties'] == {
Expand Down

0 comments on commit 3f83a0d

Please sign in to comment.