Skip to content
Myr

Drop unused interface on ConnectionStore (#70)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by GitHub · parent 8c43fca · Browse files · 4 files+21 added−22 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+21 added−22 removed

  • tests:+17 added−12 removed
  • other:+4 added−10 removed

4 files+21 added−22 removed

modified:httpcore/dispatch/connection_pool.py+1 added-7 removed
1import collections.abc1import typing23from ..concurrency import AsyncioBackend4from ..config import (
13 unmodified lines
1819CONNECTIONS_DICT = typing.Dict[Origin, typing.List[HTTPConnection]]202123class ConnectionStore(collections.abc.Sequence):22class ConnectionStore:23 """24 We need to maintain collections of connections in a way that allows us to:2526 * Lookup connections by origin.
45 unmodified lines
7273 def __iter__(self) -> typing.Iterator[HTTPConnection]:74 return iter(self.all.keys())7577 def __getitem__(self, key: typing.Any) -> typing.Any:78 if key in self.all:79 return key80 return None8176 def __len__(self) -> int:77 return len(self.all)7879
82 unmodified lines
modified:httpcore/models.py+3 added-3 removed
43 unmodified lines
44]4546AuthTypes = typing.Union[47 typing.Tuple[typing.Union[str, bytes], typing.Union[str, bytes]],48 typing.Callable[["Request"], "Request"]48 typing.Callable[["Request"], "Request"],49]5051RequestData = typing.Union[dict, bytes, typing.AsyncIterator[bytes]]52
47 unmodified lines
100101 @property102 def username(self) -> str:103 userinfo = self.components.userinfo or ""104 return userinfo.partition(':')[0]104 return userinfo.partition(":")[0]105106 @property107 def password(self) -> str:108 userinfo = self.components.userinfo or ""109 return userinfo.partition(':')[2]109 return userinfo.partition(":")[2]110111 @property112 def host(self) -> str:113 return self.components.host or ""
726 unmodified lines
modified:tests/client/test_auth.py+14 added-9 removed
1import json2from urllib.parse import parse_qs23import pytest45from httpcore import (
14 unmodified lines
20 stream: bool = False,21 ssl: SSLConfig = None,22 timeout: TimeoutConfig = None,23 ) -> Response:25 body = json.dumps({"auth": request.headers.get('Authorization')}).encode()24 body = json.dumps({"auth": request.headers.get("Authorization")}).encode()25 return Response(200, content=body, request=request)262728def test_basic_auth():29 url = "https://example.org/"31 auth = ('tomchristie', 'password123')30 auth = ("tomchristie", "password123")3132 with Client(dispatch=MockDispatch()) as client:33 response = client.get(url, auth=auth)3435 assert response.status_code == 20037 assert json.loads(response.text) == {'auth': 'Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM='}36 assert json.loads(response.text) == {37 "auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="38 }394041def test_basic_auth_in_url():42 url = "https://tomchristie:password123@example.org/"
1 unmodified line
44 with Client(dispatch=MockDispatch()) as client:45 response = client.get(url)4647 assert response.status_code == 20047 assert json.loads(response.text) == {'auth': 'Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM='}48 assert json.loads(response.text) == {49 "auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="50 }515253def test_basic_auth_on_session():54 url = "https://example.org/"52 auth = ('tomchristie', 'password123')55 auth = ("tomchristie", "password123")5657 with Client(dispatch=MockDispatch(), auth=auth) as client:58 response = client.get(url)5960 assert response.status_code == 20058 assert json.loads(response.text) == {'auth': 'Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM='}61 assert json.loads(response.text) == {62 "auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="63 }646566def test_custom_auth():67 url = "https://example.org/"6869 def auth(request):65 request.headers['Authorization'] = 'Token 123'70 request.headers["Authorization"] = "Token 123"71 return request7273 with Client(dispatch=MockDispatch()) as client:74 response = client.get(url, auth=auth)7576 assert response.status_code == 20072 assert json.loads(response.text) == {'auth': 'Token 123'}77 assert json.loads(response.text) == {"auth": "Token 123"}
modified:tests/conftest.py+3 added-3 removed
52 unmodified lines
53 await send({"type": "http.response.body", "body": b"Hello, world!"})545556async def echo_body(scope, receive, send):57 body = b''57 body = b""58 more_body = True5960 while more_body:61 message = await receive()62 body += message.get('body', b'')63 more_body = message.get('more_body', False)62 body += message.get("body", b"")63 more_body = message.get("more_body", False)6465 await send(66 {67 "type": "http.response.start",
44 unmodified lines