diff --git a/django_socio_grpc/protobuf/generation_plugin.py b/django_socio_grpc/protobuf/generation_plugin.py index d66c8682..3fb07721 100644 --- a/django_socio_grpc/protobuf/generation_plugin.py +++ b/django_socio_grpc/protobuf/generation_plugin.py @@ -223,7 +223,7 @@ def transform_message_to_list( ), ] - if hasattr(service, "pagination_class"): + if getattr(service, "pagination_class", None): fields.append( ProtoField( name="count", diff --git a/django_socio_grpc/tests/test_protobuf_registration.py b/django_socio_grpc/tests/test_protobuf_registration.py index d1095114..18c787c8 100644 --- a/django_socio_grpc/tests/test_protobuf_registration.py +++ b/django_socio_grpc/tests/test_protobuf_registration.py @@ -443,6 +443,7 @@ def test_from_serializer_nested(self): class TestGrpcActionProto(TestCase): class MyBaseAction(Service): serializer_class = MySerializer + pagination_class = None @grpc_action( request=[], @@ -583,6 +584,7 @@ def test_register_action_on_base_service_list(self): assert response.name == "BasicProtoListChildListResponse" assert response["results"].field_type.name == "BasicProtoListChildResponse" + assert "count" not in response request = proto_rpc.request @@ -763,6 +765,8 @@ def test_register_action_list_with_struct_pagination(self): assert response.name == "BasicProtoListChildListResponse" assert response["results"].field_type.name == "BasicProtoListChildResponse" + assert "count" in response + assert response["count"].field_type == "int32" request = proto_rpc.request