Skip to content

Commit

Permalink
fix having a pagination class attribute set to None
Browse files Browse the repository at this point in the history
  • Loading branch information
AMontagu committed Apr 8, 2024
1 parent 312d62e commit 0b7a3ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django_socio_grpc/protobuf/generation_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions django_socio_grpc/tests/test_protobuf_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 0b7a3ec

Please sign in to comment.