@@ -1016,6 +1016,44 @@ async def handler(request):
1016
1016
assert received_answer == expected_answer
1017
1017
1018
1018
1019
+ @pytest .mark .asyncio
1020
+ @pytest .mark .script_launch_mode ("subprocess" )
1021
+ async def test_aiohttp_using_cli_ep (
1022
+ event_loop , aiohttp_server , monkeypatch , script_runner , run_sync_test
1023
+ ):
1024
+ from aiohttp import web
1025
+
1026
+ async def handler (request ):
1027
+ return web .Response (text = query1_server_answer , content_type = "application/json" )
1028
+
1029
+ app = web .Application ()
1030
+ app .router .add_route ("POST" , "/" , handler )
1031
+ server = await aiohttp_server (app )
1032
+
1033
+ url = str (server .make_url ("/" ))
1034
+
1035
+ def test_code ():
1036
+
1037
+ monkeypatch .setattr ("sys.stdin" , io .StringIO (query1_str ))
1038
+
1039
+ ret = script_runner .run (
1040
+ "gql-cli" , url , "--verbose" , stdin = io .StringIO (query1_str )
1041
+ )
1042
+
1043
+ assert ret .success
1044
+
1045
+ # Check that the result has been printed on stdout
1046
+ captured_out = str (ret .stdout ).strip ()
1047
+
1048
+ expected_answer = json .loads (query1_server_answer_data )
1049
+ print (f"Captured: { captured_out } " )
1050
+ received_answer = json .loads (captured_out )
1051
+
1052
+ assert received_answer == expected_answer
1053
+
1054
+ await run_sync_test (event_loop , server , test_code )
1055
+
1056
+
1019
1057
@pytest .mark .asyncio
1020
1058
async def test_aiohttp_using_cli_invalid_param (
1021
1059
event_loop , aiohttp_server , monkeypatch , capsys
0 commit comments