Skip to content

Commit 28d97fa

Browse files
committed
move console_script tests back into integrated files
1 parent 0db64ae commit 28d97fa

File tree

3 files changed

+49
-60
lines changed

3 files changed

+49
-60
lines changed

tests/test_aiohttp.py

+38
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,44 @@ async def handler(request):
10161016
assert received_answer == expected_answer
10171017

10181018

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+
10191057
@pytest.mark.asyncio
10201058
async def test_aiohttp_using_cli_invalid_param(
10211059
event_loop, aiohttp_server, monkeypatch, capsys

tests/test_cli.py

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import pytest
44

5+
from gql import __version__
6+
57
from gql.cli import (
68
get_execute_args,
79
get_parser,
@@ -338,3 +340,12 @@ def test_cli_get_transport_no_protocol(parser):
338340

339341
with pytest.raises(ValueError):
340342
get_transport(args)
343+
344+
345+
def test_cli_ep_version(script_runner):
346+
ret = script_runner.run("gql-cli", "--version")
347+
348+
assert ret.success
349+
350+
assert ret.stdout == f"v{__version__}\n"
351+
assert ret.stderr == ""

tests/test_console_scripts.py

-60
This file was deleted.

0 commit comments

Comments
 (0)