def test_user_list_serializer_none_data() -> None: serializer = UserListSerializer(data=None) assert not serializer.is_valid() assert serializer.validated_data == {} assert serializer.data == {} assert "non_field_errors" in serializer.errors assert serializer.errors["non_field_errors"][0].code == "null"
def test_user_list_serializer_valid() -> None: input_data = { "first_name": "Karol", "last_name": "Guzikowski", } serializer = UserListSerializer(data=input_data) assert serializer.is_valid() assert serializer.validated_data == input_data assert serializer.data == input_data
def test_user_list_serializer_not_valid_missing_field() -> None: input_data = { "last_name": "Guzikowski", } serializer = UserListSerializer(data=input_data) assert not serializer.is_valid() assert serializer.validated_data == {} assert serializer.data == input_data assert "first_name" in serializer.errors assert serializer.errors["first_name"][0].code == "required"