Skip to content

Commit a0f75a5

Browse files
committed
Rename sample_transport to transport once and for all
1 parent a2a3524 commit a0f75a5

10 files changed

+90
-104
lines changed

tests/test_aiohttp_online.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ async def test_aiohttp_simple_query():
1919
url = "https://countries.trevorblades.com/graphql"
2020

2121
# Get transport
22-
sample_transport = AIOHTTPTransport(url=url)
22+
transport = AIOHTTPTransport(url=url)
2323

2424
# Instanciate client
25-
async with Client(transport=sample_transport) as session:
25+
async with Client(transport=transport) as session:
2626

2727
query = gql(
2828
"""
@@ -60,11 +60,9 @@ async def test_aiohttp_invalid_query():
6060

6161
from gql.transport.aiohttp import AIOHTTPTransport
6262

63-
sample_transport = AIOHTTPTransport(
64-
url="https://countries.trevorblades.com/graphql"
65-
)
63+
transport = AIOHTTPTransport(url="https://countries.trevorblades.com/graphql")
6664

67-
async with Client(transport=sample_transport) as session:
65+
async with Client(transport=transport) as session:
6866

6967
query = gql(
7068
"""
@@ -89,12 +87,12 @@ async def test_aiohttp_two_queries_in_parallel_using_two_tasks():
8987

9088
from gql.transport.aiohttp import AIOHTTPTransport
9189

92-
sample_transport = AIOHTTPTransport(
90+
transport = AIOHTTPTransport(
9391
url="https://countries.trevorblades.com/graphql",
9492
)
9593

9694
# Instanciate client
97-
async with Client(transport=sample_transport) as session:
95+
async with Client(transport=transport) as session:
9896

9997
query1 = gql(
10098
"""

tests/test_appsync_auth.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ def test_appsync_init_with_minimal_args(fake_session_factory):
99
from gql.transport.appsync_auth import AppSyncIAMAuthentication
1010
from gql.transport.appsync_websockets import AppSyncWebsocketsTransport
1111

12-
sample_transport = AppSyncWebsocketsTransport(
12+
transport = AppSyncWebsocketsTransport(
1313
url=mock_transport_url, session=fake_session_factory()
1414
)
15-
assert isinstance(sample_transport.auth, AppSyncIAMAuthentication)
16-
assert sample_transport.connect_timeout == 10
17-
assert sample_transport.close_timeout == 10
18-
assert sample_transport.ack_timeout == 10
19-
assert sample_transport.ssl is False
20-
assert sample_transport.connect_args == {}
15+
assert isinstance(transport.auth, AppSyncIAMAuthentication)
16+
assert transport.connect_timeout == 10
17+
assert transport.close_timeout == 10
18+
assert transport.ack_timeout == 10
19+
assert transport.ssl is False
20+
assert transport.connect_args == {}
2121

2222

2323
@pytest.mark.botocore
@@ -27,11 +27,11 @@ def test_appsync_init_with_no_credentials(caplog, fake_session_factory):
2727
from gql.transport.appsync_websockets import AppSyncWebsocketsTransport
2828

2929
with pytest.raises(botocore.exceptions.NoCredentialsError):
30-
sample_transport = AppSyncWebsocketsTransport(
30+
transport = AppSyncWebsocketsTransport(
3131
url=mock_transport_url,
3232
session=fake_session_factory(credentials=None),
3333
)
34-
assert sample_transport.auth is None
34+
assert transport.auth is None
3535

3636
expected_error = "Credentials not found"
3737

@@ -46,8 +46,8 @@ def test_appsync_init_with_jwt_auth():
4646
from gql.transport.appsync_websockets import AppSyncWebsocketsTransport
4747

4848
auth = AppSyncJWTAuthentication(host=mock_transport_host, jwt="some-jwt")
49-
sample_transport = AppSyncWebsocketsTransport(url=mock_transport_url, auth=auth)
50-
assert sample_transport.auth is auth
49+
transport = AppSyncWebsocketsTransport(url=mock_transport_url, auth=auth)
50+
assert transport.auth is auth
5151

5252
assert auth.get_headers() == {
5353
"host": mock_transport_host,
@@ -61,8 +61,8 @@ def test_appsync_init_with_apikey_auth():
6161
from gql.transport.appsync_websockets import AppSyncWebsocketsTransport
6262

6363
auth = AppSyncApiKeyAuthentication(host=mock_transport_host, api_key="some-api-key")
64-
sample_transport = AppSyncWebsocketsTransport(url=mock_transport_url, auth=auth)
65-
assert sample_transport.auth is auth
64+
transport = AppSyncWebsocketsTransport(url=mock_transport_url, auth=auth)
65+
assert transport.auth is auth
6666

6767
assert auth.get_headers() == {
6868
"host": mock_transport_host,
@@ -95,8 +95,8 @@ def test_appsync_init_with_iam_auth_with_creds(fake_credentials_factory):
9595
credentials=fake_credentials_factory(),
9696
region_name="us-east-1",
9797
)
98-
sample_transport = AppSyncWebsocketsTransport(url=mock_transport_url, auth=auth)
99-
assert sample_transport.auth is auth
98+
transport = AppSyncWebsocketsTransport(url=mock_transport_url, auth=auth)
99+
assert transport.auth is auth
100100

101101

102102
@pytest.mark.botocore
@@ -153,7 +153,7 @@ def test_munge_url(fake_signer_factory, fake_request_factory):
153153
signer=fake_signer_factory(),
154154
request_creator=fake_request_factory,
155155
)
156-
sample_transport = AppSyncWebsocketsTransport(url=test_url, auth=auth)
156+
transport = AppSyncWebsocketsTransport(url=test_url, auth=auth)
157157

158158
header_string = (
159159
"eyJGYWtlQXV0aG9yaXphdGlvbiI6ImEiLCJGYWtlVGltZSI6InRvZGF5"
@@ -164,7 +164,7 @@ def test_munge_url(fake_signer_factory, fake_request_factory):
164164
"wss://appsync-realtime-api.aws.example.org/"
165165
f"some-other-params?header={header_string}&payload=e30="
166166
)
167-
assert sample_transport.url == expected_url
167+
assert transport.url == expected_url
168168

169169

170170
@pytest.mark.botocore

tests/test_appsync_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ async def handler(request):
4949
region_name="us-east-1",
5050
)
5151

52-
sample_transport = AIOHTTPTransport(url=url, auth=auth)
52+
transport = AIOHTTPTransport(url=url, auth=auth)
5353

54-
async with Client(transport=sample_transport) as session:
54+
async with Client(transport=transport) as session:
5555

5656
query = gql(
5757
"""

tests/test_async_client_validation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ async def test_async_client_validation(server, subscription_str, client_params):
9191

9292
url = f"ws://{server.hostname}:{server.port}/graphql"
9393

94-
sample_transport = WebsocketsTransport(url=url)
94+
transport = WebsocketsTransport(url=url)
9595

96-
client = Client(transport=sample_transport, **client_params)
96+
client = Client(transport=transport, **client_params)
9797

9898
async with client as session:
9999

@@ -138,9 +138,9 @@ async def test_async_client_validation_invalid_query(
138138

139139
url = f"ws://{server.hostname}:{server.port}/graphql"
140140

141-
sample_transport = WebsocketsTransport(url=url)
141+
transport = WebsocketsTransport(url=url)
142142

143-
client = Client(transport=sample_transport, **client_params)
143+
client = Client(transport=transport, **client_params)
144144

145145
async with client as session:
146146

@@ -171,10 +171,10 @@ async def test_async_client_validation_different_schemas_parameters_forbidden(
171171

172172
url = f"ws://{server.hostname}:{server.port}/graphql"
173173

174-
sample_transport = WebsocketsTransport(url=url)
174+
transport = WebsocketsTransport(url=url)
175175

176176
with pytest.raises(AssertionError):
177-
async with Client(transport=sample_transport, **client_params):
177+
async with Client(transport=transport, **client_params):
178178
pass
179179

180180

@@ -261,10 +261,10 @@ async def test_async_client_validation_fetch_schema_from_server_with_client_argu
261261

262262
url = f"ws://{server.hostname}:{server.port}/graphql"
263263

264-
sample_transport = WebsocketsTransport(url=url)
264+
transport = WebsocketsTransport(url=url)
265265

266266
async with Client(
267-
transport=sample_transport,
267+
transport=transport,
268268
fetch_schema_from_transport=True,
269269
) as session:
270270

tests/test_http_async_sync.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ async def test_async_client_async_transport(fetch_schema_from_transport):
1515
url = "https://countries.trevorblades.com/graphql"
1616

1717
# Get async transport
18-
sample_transport = AIOHTTPTransport(url=url)
18+
transport = AIOHTTPTransport(url=url)
1919

2020
# Instantiate client
2121
async with Client(
22-
transport=sample_transport,
22+
transport=transport,
2323
fetch_schema_from_transport=fetch_schema_from_transport,
2424
) as session:
2525

@@ -58,17 +58,17 @@ async def test_async_client_sync_transport(fetch_schema_from_transport):
5858
url = "http://countries.trevorblades.com/graphql"
5959

6060
# Get sync transport
61-
sample_transport = RequestsHTTPTransport(url=url, use_json=True)
61+
transport = RequestsHTTPTransport(url=url, use_json=True)
6262

6363
# Impossible to use a sync transport asynchronously
6464
with pytest.raises(AssertionError):
6565
async with Client(
66-
transport=sample_transport,
66+
transport=transport,
6767
fetch_schema_from_transport=fetch_schema_from_transport,
6868
):
6969
pass
7070

71-
sample_transport.close()
71+
transport.close()
7272

7373

7474
@pytest.mark.aiohttp
@@ -82,11 +82,11 @@ def test_sync_client_async_transport(fetch_schema_from_transport):
8282
url = "https://countries.trevorblades.com/graphql"
8383

8484
# Get async transport
85-
sample_transport = AIOHTTPTransport(url=url)
85+
transport = AIOHTTPTransport(url=url)
8686

8787
# Instanciate client
8888
client = Client(
89-
transport=sample_transport,
89+
transport=transport,
9090
fetch_schema_from_transport=fetch_schema_from_transport,
9191
)
9292

@@ -125,11 +125,11 @@ def test_sync_client_sync_transport(fetch_schema_from_transport):
125125
url = "https://countries.trevorblades.com/graphql"
126126

127127
# Get sync transport
128-
sample_transport = RequestsHTTPTransport(url=url, use_json=True)
128+
transport = RequestsHTTPTransport(url=url, use_json=True)
129129

130130
# Instanciate client
131131
client = Client(
132-
transport=sample_transport,
132+
transport=transport,
133133
fetch_schema_from_transport=fetch_schema_from_transport,
134134
)
135135

tests/test_httpx_online.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ async def test_httpx_simple_query():
1919
url = "https://countries.trevorblades.com/graphql"
2020

2121
# Get transport
22-
sample_transport = HTTPXAsyncTransport(url=url)
22+
transport = HTTPXAsyncTransport(url=url)
2323

2424
# Instanciate client
25-
async with Client(transport=sample_transport) as session:
25+
async with Client(transport=transport) as session:
2626

2727
query = gql(
2828
"""
@@ -60,11 +60,9 @@ async def test_httpx_invalid_query():
6060

6161
from gql.transport.httpx import HTTPXAsyncTransport
6262

63-
sample_transport = HTTPXAsyncTransport(
64-
url="https://countries.trevorblades.com/graphql"
65-
)
63+
transport = HTTPXAsyncTransport(url="https://countries.trevorblades.com/graphql")
6664

67-
async with Client(transport=sample_transport) as session:
65+
async with Client(transport=transport) as session:
6866

6967
query = gql(
7068
"""
@@ -89,12 +87,12 @@ async def test_httpx_two_queries_in_parallel_using_two_tasks():
8987

9088
from gql.transport.httpx import HTTPXAsyncTransport
9189

92-
sample_transport = HTTPXAsyncTransport(
90+
transport = HTTPXAsyncTransport(
9391
url="https://countries.trevorblades.com/graphql",
9492
)
9593

9694
# Instanciate client
97-
async with Client(transport=sample_transport) as session:
95+
async with Client(transport=transport) as session:
9896

9997
query1 = gql(
10098
"""

tests/test_phoenix_channel_exceptions.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,11 @@ async def test_phoenix_channel_query_protocol_error(server, query_str):
167167

168168
path = "/graphql"
169169
url = f"ws://{server.hostname}:{server.port}{path}"
170-
sample_transport = PhoenixChannelWebsocketsTransport(
171-
channel_name="test_channel", url=url
172-
)
170+
transport = PhoenixChannelWebsocketsTransport(channel_name="test_channel", url=url)
173171

174172
query = gql(query_str)
175173
with pytest.raises(TransportProtocolError):
176-
async with Client(transport=sample_transport) as session:
174+
async with Client(transport=transport) as session:
177175
await session.execute(query)
178176

179177

@@ -197,13 +195,11 @@ async def test_phoenix_channel_query_error(server, query_str):
197195

198196
path = "/graphql"
199197
url = f"ws://{server.hostname}:{server.port}{path}"
200-
sample_transport = PhoenixChannelWebsocketsTransport(
201-
channel_name="test_channel", url=url
202-
)
198+
transport = PhoenixChannelWebsocketsTransport(channel_name="test_channel", url=url)
203199

204200
query = gql(query_str)
205201
with pytest.raises(TransportQueryError):
206-
async with Client(transport=sample_transport) as session:
202+
async with Client(transport=transport) as session:
207203
await session.execute(query)
208204

209205

@@ -414,13 +410,11 @@ async def test_phoenix_channel_subscription_protocol_error(server, query_str):
414410

415411
path = "/graphql"
416412
url = f"ws://{server.hostname}:{server.port}{path}"
417-
sample_transport = PhoenixChannelWebsocketsTransport(
418-
channel_name="test_channel", url=url
419-
)
413+
transport = PhoenixChannelWebsocketsTransport(channel_name="test_channel", url=url)
420414

421415
query = gql(query_str)
422416
with pytest.raises(TransportProtocolError):
423-
async with Client(transport=sample_transport) as session:
417+
async with Client(transport=transport) as session:
424418
async for _result in session.subscribe(query):
425419
await asyncio.sleep(10 * MS)
426420
break
@@ -444,13 +438,11 @@ async def test_phoenix_channel_server_error(server, query_str):
444438

445439
path = "/graphql"
446440
url = f"ws://{server.hostname}:{server.port}{path}"
447-
sample_transport = PhoenixChannelWebsocketsTransport(
448-
channel_name="test_channel", url=url
449-
)
441+
transport = PhoenixChannelWebsocketsTransport(channel_name="test_channel", url=url)
450442

451443
query = gql(query_str)
452444
with pytest.raises(TransportServerError):
453-
async with Client(transport=sample_transport) as session:
445+
async with Client(transport=transport) as session:
454446
await session.execute(query)
455447

456448

@@ -476,12 +468,12 @@ async def test_phoenix_channel_unsubscribe_error(server, query_str):
476468

477469
# Reduce close_timeout. These tests will wait for an unsubscribe
478470
# reply that will never come...
479-
sample_transport = PhoenixChannelWebsocketsTransport(
471+
transport = PhoenixChannelWebsocketsTransport(
480472
channel_name="test_channel", url=url, close_timeout=1
481473
)
482474

483475
query = gql(query_str)
484-
async with Client(transport=sample_transport) as session:
476+
async with Client(transport=transport) as session:
485477
async for _result in session.subscribe(query):
486478
break
487479

@@ -504,13 +496,13 @@ async def test_phoenix_channel_unsubscribe_error_forcing(server, query_str):
504496
path = "/graphql"
505497
url = f"ws://{server.hostname}:{server.port}{path}"
506498

507-
sample_transport = PhoenixChannelWebsocketsTransport(
499+
transport = PhoenixChannelWebsocketsTransport(
508500
channel_name="test_channel", url=url, close_timeout=1
509501
)
510502

511503
query = gql(query_str)
512504
with pytest.raises(TransportProtocolError):
513-
async with Client(transport=sample_transport) as session:
505+
async with Client(transport=transport) as session:
514506
async for _result in session.subscribe(query):
515507
await session.transport._send_stop_message(2)
516508
await asyncio.sleep(10 * MS)

0 commit comments

Comments
 (0)