File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -899,3 +899,41 @@ async def test_graphqlws_subscription_reconnecting_session(
899899 break
900900
901901 assert transport ._connected is False
902+
903+
904+ @pytest .mark .asyncio
905+ @pytest .mark .parametrize ("server" , [server_countdown ], indirect = True )
906+ @pytest .mark .parametrize ("subscription_str" , [countdown_subscription_str ])
907+ async def test_graphqlws_subscription_no_server_protocol (server , subscription_str ):
908+ """The goal of this test is to verify that if the client requests only the
909+ graphqlws subprotocol AND the server is not returning its subprotocol
910+ in its header, then the client will assume that the protocol used is
911+ the graphqlws subprotocol (See PR #586).
912+ """
913+
914+ from gql .transport .websockets import WebsocketsTransport
915+
916+ url = f"ws://{ server .hostname } :{ server .port } /graphql"
917+ print (f"url = { url } " )
918+
919+ transport = WebsocketsTransport (
920+ url = url ,
921+ subprotocols = [WebsocketsTransport .GRAPHQLWS_SUBPROTOCOL ],
922+ keep_alive_timeout = 3 ,
923+ )
924+
925+ client = Client (transport = transport )
926+
927+ count = 10
928+ subscription = gql (subscription_str .format (count = count ))
929+
930+ async with client as session :
931+ async for result in session .subscribe (subscription ):
932+
933+ number = result ["number" ]
934+ print (f"Number received: { number } " )
935+
936+ assert number == count
937+ count -= 1
938+
939+ assert count == - 1
You can’t perform that action at this time.
0 commit comments