Skip to content

Commit 2afec24

Browse files
authored
chore: Bump httpx to 0.21.3 (#114)
1 parent 5784593 commit 2afec24

File tree

9 files changed

+41
-46
lines changed

9 files changed

+41
-46
lines changed

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ packages = find:
2525
install_requires =
2626
aiorwlock==1.1.0
2727
async-property==0.2.1
28-
httpx[http2]==0.19.0
28+
httpx[http2]==0.21.3
2929
pydantic[dotenv]==1.8.2
3030
readerwriterlock==1.0.9
3131
sqlparse>=0.4.2
@@ -47,7 +47,7 @@ dev =
4747
pytest==6.2.5
4848
pytest-asyncio
4949
pytest-cov==3.0.0
50-
pytest-httpx==0.13.0
50+
pytest-httpx==0.18.0
5151
pytest-mock==3.6.1
5252

5353
[options.package_data]

tests/unit/async_db/conftest.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from httpx import URL, Request, Response, codes
66
from pytest import fixture
7-
from pytest_httpx import to_response
87

98
from firebolt.async_db import ARRAY, Connection, Cursor, connect
109
from firebolt.async_db.cursor import JSON_OUTPUT_FORMAT, ColType, Column
@@ -115,7 +114,7 @@ def do_query(request: Request, **kwargs) -> Response:
115114
"scanned_bytes_storage": 0,
116115
},
117116
}
118-
return to_response(status_code=codes.OK, json=query_response)
117+
return Response(status_code=codes.OK, json=query_response)
119118

120119
return do_query
121120

@@ -147,7 +146,7 @@ def do_query(request: Request, **kwargs) -> Response:
147146
"scanned_bytes_storage": 0,
148147
},
149148
}
150-
return to_response(status_code=codes.OK, json=query_response)
149+
return Response(status_code=codes.OK, json=query_response)
151150

152151
return do_query
153152

@@ -157,7 +156,7 @@ def insert_query_callback(
157156
query_description: List[Column], query_data: List[List[ColType]]
158157
) -> Callable:
159158
def do_query(request: Request, **kwargs) -> Response:
160-
return to_response(status_code=codes.OK, headers={"content-length": "0"})
159+
return Response(status_code=codes.OK, headers={"content-length": "0"})
161160

162161
return do_query
163162

@@ -174,7 +173,7 @@ def set_params() -> Dict:
174173
@fixture
175174
def query_url(settings: Settings, db_name: str) -> str:
176175
return URL(
177-
f"https://{settings.server}?database={db_name}"
176+
f"https://{settings.server}/?database={db_name}"
178177
f"&output_format={JSON_OUTPUT_FORMAT}"
179178
)
180179

tests/unit/async_db/test_cursor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ async def test_cursor_execute_error(
206206
httpx_mock.add_callback(auth_callback, url=auth_url)
207207

208208
# Internal httpx error
209-
def http_error(**kwargs):
209+
def http_error(*args, **kwargs):
210210
raise StreamError("httpx error")
211211

212212
httpx_mock.add_callback(http_error, url=query_url)
@@ -228,7 +228,7 @@ def http_error(**kwargs):
228228
# Database query error
229229
httpx_mock.add_response(
230230
status_code=codes.INTERNAL_SERVER_ERROR,
231-
data="Query error message",
231+
content="Query error message",
232232
url=query_url,
233233
)
234234
with raises(OperationalError) as excinfo:
@@ -242,7 +242,7 @@ def http_error(**kwargs):
242242
# Database does not exist error
243243
httpx_mock.add_response(
244244
status_code=codes.FORBIDDEN,
245-
data="Query error message",
245+
content="Query error message",
246246
url=query_url,
247247
)
248248
httpx_mock.add_response(
@@ -256,7 +256,7 @@ def http_error(**kwargs):
256256
# Engine is not running error
257257
httpx_mock.add_response(
258258
status_code=codes.SERVICE_UNAVAILABLE,
259-
data="Query error message",
259+
content="Query error message",
260260
url=query_url,
261261
)
262262
httpx_mock.add_response(

tests/unit/client/conftest.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
import httpx
55
import pytest
6-
from pytest_httpx import to_response
7-
from pytest_httpx._httpx_internals import Response
6+
from httpx import Response
87

98

109
@pytest.fixture
@@ -42,7 +41,7 @@ def check_credentials(
4241
assert "password" in body, "Missing password"
4342
assert body["password"] == test_password, "Invalid password"
4443

45-
return to_response(
44+
return Response(
4645
status_code=httpx.codes.OK,
4746
json={"expires_in": 2 ** 32, "access_token": test_token},
4847
)
@@ -61,6 +60,6 @@ def check_token(request: httpx.Request = None, **kwargs) -> Response:
6160
token = auth[len(prefix) :]
6261
assert token == test_token, "invalid authorization token"
6362

64-
return to_response(status_code=httpx.codes.OK)
63+
return Response(status_code=httpx.codes.OK)
6564

6665
return check_token

tests/unit/client/test_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_auth_error_handling(httpx_mock: HTTPXMock):
9999
auth = Auth("user", "password", api_endpoint=api_endpoint)
100100

101101
# Internal httpx error
102-
def http_error(**kwargs):
102+
def http_error(*args, **kwargs):
103103
raise StreamError("httpx")
104104

105105
httpx_mock.add_callback(http_error)

tests/unit/conftest.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import httpx
44
import pytest
5+
from httpx import Response
56
from pydantic import SecretStr
6-
from pytest_httpx import to_response
7-
from pytest_httpx._httpx_internals import Response
87

98
from firebolt.common.exception import (
109
DatabaseError,
@@ -106,7 +105,7 @@ def do_mock(
106105
**kwargs,
107106
) -> Response:
108107
assert request.url == auth_url
109-
return to_response(
108+
return Response(
110109
status_code=httpx.codes.OK,
111110
json={"access_token": "", "expires_in": 2 ** 32},
112111
)
@@ -150,11 +149,11 @@ def do_mock(
150149
) -> Response:
151150
assert request.url == account_id_url
152151
if account_id_url.endswith(ACCOUNT_URL): # account_name shouldn't be specified.
153-
return to_response(
152+
return Response(
154153
status_code=httpx.codes.OK, json={"account": {"id": account_id}}
155154
)
156155
# In this case, an account_name *should* be specified.
157-
return to_response(status_code=httpx.codes.OK, json={"account_id": account_id})
156+
return Response(status_code=httpx.codes.OK, json={"account_id": account_id})
158157

159158
return do_mock
160159

@@ -180,7 +179,7 @@ def do_mock(
180179
**kwargs,
181180
) -> Response:
182181
assert request.url == get_engine_url
183-
return to_response(
182+
return Response(
184183
status_code=httpx.codes.OK,
185184
json={
186185
"engine": {
@@ -216,7 +215,7 @@ def do_mock(
216215
**kwargs,
217216
) -> Response:
218217
assert request.url == get_providers_url
219-
return to_response(
218+
return Response(
220219
status_code=httpx.codes.OK,
221220
json=list_to_paginated_response([provider]),
222221
)

tests/unit/db/conftest.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from httpx import URL, Request, Response, codes
66
from pytest import fixture
7-
from pytest_httpx import to_response
87

98
from firebolt.async_db.cursor import JSON_OUTPUT_FORMAT, ColType, Column
109
from firebolt.common.settings import Settings
@@ -115,7 +114,7 @@ def do_query(request: Request, **kwargs) -> Response:
115114
"scanned_bytes_storage": 0,
116115
},
117116
}
118-
return to_response(status_code=codes.OK, json=query_response)
117+
return Response(status_code=codes.OK, json=query_response)
119118

120119
return do_query
121120

@@ -147,7 +146,7 @@ def do_query(request: Request, **kwargs) -> Response:
147146
"scanned_bytes_storage": 0,
148147
},
149148
}
150-
return to_response(status_code=codes.OK, json=query_response)
149+
return Response(status_code=codes.OK, json=query_response)
151150

152151
return do_query
153152

@@ -157,7 +156,7 @@ def insert_query_callback(
157156
query_description: List[Column], query_data: List[List[ColType]]
158157
) -> Callable:
159158
def do_query(request: Request, **kwargs) -> Response:
160-
return to_response(status_code=codes.OK, headers={"content-length": "0"})
159+
return Response(status_code=codes.OK, headers={"content-length": "0"})
161160

162161
return do_query
163162

@@ -174,7 +173,7 @@ def set_params() -> Dict:
174173
@fixture
175174
def query_url(settings: Settings, db_name: str) -> str:
176175
return URL(
177-
f"https://{settings.server}?database={db_name}"
176+
f"https://{settings.server}/?database={db_name}"
178177
f"&output_format={JSON_OUTPUT_FORMAT}"
179178
)
180179

tests/unit/db/test_cursor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def test_cursor_execute_error(
190190
httpx_mock.add_callback(auth_callback, url=auth_url)
191191

192192
# Internal httpx error
193-
def http_error(**kwargs):
193+
def http_error(*args, **kwargs):
194194
raise StreamError("httpx error")
195195

196196
httpx_mock.add_callback(http_error, url=query_url)
@@ -212,7 +212,7 @@ def http_error(**kwargs):
212212
# Database query error
213213
httpx_mock.add_response(
214214
status_code=codes.INTERNAL_SERVER_ERROR,
215-
data="Query error message",
215+
content="Query error message",
216216
url=query_url,
217217
)
218218
with raises(OperationalError) as excinfo:

tests/unit/service/conftest.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
import httpx
55
import pytest
6-
from pytest_httpx import to_response
7-
from pytest_httpx._httpx_internals import Response
6+
from httpx import Response
87

98
from firebolt.common.settings import Settings
109
from firebolt.common.urls import (
@@ -83,7 +82,7 @@ def do_mock(
8382
**kwargs,
8483
) -> Response:
8584
assert request.url == provider_url
86-
return to_response(
85+
return Response(
8786
status_code=httpx.codes.OK,
8887
json=list_to_paginated_response(mock_providers),
8988
)
@@ -103,7 +102,7 @@ def do_mock(
103102
**kwargs,
104103
) -> Response:
105104
assert request.url == region_url
106-
return to_response(
105+
return Response(
107106
status_code=httpx.codes.OK,
108107
json=list_to_paginated_response(mock_regions),
109108
)
@@ -123,7 +122,7 @@ def do_mock(
123122
**kwargs,
124123
) -> Response:
125124
assert request.url == instance_type_url
126-
return to_response(
125+
return Response(
127126
status_code=httpx.codes.OK,
128127
json=list_to_paginated_response(mock_instance_types),
129128
)
@@ -143,7 +142,7 @@ def do_mock(
143142
**kwargs,
144143
) -> Response:
145144
assert request.url == engine_url
146-
return to_response(
145+
return Response(
147146
status_code=httpx.codes.OK,
148147
json={"engine": mock_engine.dict()},
149148
)
@@ -165,7 +164,7 @@ def do_mock(
165164
**kwargs,
166165
) -> Response:
167166
assert request.url == account_engine_url
168-
return to_response(
167+
return Response(
169168
status_code=httpx.codes.OK,
170169
json={"engine": mock_engine.dict()},
171170
)
@@ -205,7 +204,7 @@ def do_mock(
205204
mock_database.description = database_properties["description"]
206205

207206
assert request.url == databases_url
208-
return to_response(
207+
return Response(
209208
status_code=httpx.codes.OK,
210209
json={"database": mock_database.dict()},
211210
)
@@ -218,7 +217,7 @@ def databases_get_callback(databases_url: str, mock_database) -> Callable:
218217
def get_databases_callback_inner(
219218
request: httpx.Request = None, **kwargs
220219
) -> Response:
221-
return to_response(
220+
return Response(
222221
status_code=httpx.codes.OK, json={"edges": [{"node": mock_database.dict()}]}
223222
)
224223

@@ -239,7 +238,7 @@ def do_mock(
239238
**kwargs,
240239
) -> Response:
241240
assert request.url == database_url
242-
return to_response(
241+
return Response(
243242
status_code=httpx.codes.OK,
244243
json={"database": mock_database.dict()},
245244
)
@@ -254,7 +253,7 @@ def do_mock(
254253
**kwargs,
255254
) -> Response:
256255
assert request.url == database_url
257-
return to_response(
256+
return Response(
258257
status_code=httpx.codes.OK,
259258
json={},
260259
)
@@ -276,7 +275,7 @@ def do_mock(
276275
**kwargs,
277276
) -> Response:
278277
assert request.url == database_get_by_name_url
279-
return to_response(
278+
return Response(
280279
status_code=httpx.codes.OK,
281280
json={"database_id": {"database_id": mock_database.database_id}},
282281
)
@@ -300,7 +299,7 @@ def do_mock(
300299
**kwargs,
301300
) -> Response:
302301
assert request.url == database_get_url
303-
return to_response(
302+
return Response(
304303
status_code=httpx.codes.OK,
305304
json={"database": mock_database.dict()},
306305
)
@@ -335,7 +334,7 @@ def do_mock(
335334
**kwargs,
336335
) -> Response:
337336
assert request.url == bindings_url
338-
return to_response(
337+
return Response(
339338
status_code=httpx.codes.OK,
340339
json=list_to_paginated_response([binding]),
341340
)
@@ -350,7 +349,7 @@ def do_mock(
350349
**kwargs,
351350
) -> Response:
352351
assert request.url == bindings_url
353-
return to_response(
352+
return Response(
354353
status_code=httpx.codes.OK,
355354
json=list_to_paginated_response([]),
356355
)
@@ -374,7 +373,7 @@ def do_mock(
374373
**kwargs,
375374
) -> Response:
376375
assert request.url == create_binding_url
377-
return to_response(
376+
return Response(
378377
status_code=httpx.codes.OK,
379378
json={"binding": binding.dict()},
380379
)

0 commit comments

Comments
 (0)