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
Provenance
- Commit
3ed0885- Tree
79b29ad- Author
Tom Christie <tom@tomchristie.com>- Committer
GitHub <noreply@github.com>- Parent
8c43fca
4 files changed+21 added−22 removed
modified:httpcore/dispatch/connection_pool.py+1 added-7 removed
1-import collections.abc1 import typing2 3 from ..concurrency import AsyncioBackend4 from ..config import (13 unmodified lines18 19 CONNECTIONS_DICT = typing.Dict[Origin, typing.List[HTTPConnection]]20 21 23-class ConnectionStore(collections.abc.Sequence):22+class ConnectionStore:23 """24 We need to maintain collections of connections in a way that allows us to:25 26 * Lookup connections by origin.45 unmodified lines72 73 def __iter__(self) -> typing.Iterator[HTTPConnection]:74 return iter(self.all.keys())75 77- def __getitem__(self, key: typing.Any) -> typing.Any:78- if key in self.all:79- return key80- return None81-76 def __len__(self) -> int:77 return len(self.all)78 79 82 unmodified linesmodified:httpcore/models.py+3 added-3 removed
43 unmodified lines44 ]45 46 AuthTypes = typing.Union[47 typing.Tuple[typing.Union[str, bytes], typing.Union[str, bytes]],48- typing.Callable[["Request"], "Request"]48+ typing.Callable[["Request"], "Request"],49 ]50 51 RequestData = typing.Union[dict, bytes, typing.AsyncIterator[bytes]]52 47 unmodified lines100 101 @property102 def username(self) -> str:103 userinfo = self.components.userinfo or ""104- return userinfo.partition(':')[0]104+ return userinfo.partition(":")[0]105 106 @property107 def password(self) -> str:108 userinfo = self.components.userinfo or ""109- return userinfo.partition(':')[2]109+ return userinfo.partition(":")[2]110 111 @property112 def host(self) -> str:113 return self.components.host or ""726 unmodified linesmodified:tests/client/test_auth.py+14 added-9 removed
1 import json2-from urllib.parse import parse_qs2 3 import pytest4 5 from httpcore import (14 unmodified lines20 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)26 27 28 def test_basic_auth():29 url = "https://example.org/"31- auth = ('tomchristie', 'password123')30+ auth = ("tomchristie", "password123")31 32 with Client(dispatch=MockDispatch()) as client:33 response = client.get(url, auth=auth)34 35 assert response.status_code == 20037- assert json.loads(response.text) == {'auth': 'Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM='}36+ assert json.loads(response.text) == {37+ "auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="38+ }39 40 41 def test_basic_auth_in_url():42 url = "https://tomchristie:password123@example.org/"1 unmodified line44 with Client(dispatch=MockDispatch()) as client:45 response = client.get(url)46 47 assert response.status_code == 20047- assert json.loads(response.text) == {'auth': 'Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM='}48+ assert json.loads(response.text) == {49+ "auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="50+ }51 52 53 def test_basic_auth_on_session():54 url = "https://example.org/"52- auth = ('tomchristie', 'password123')55+ auth = ("tomchristie", "password123")56 57 with Client(dispatch=MockDispatch(), auth=auth) as client:58 response = client.get(url)59 60 assert response.status_code == 20058- assert json.loads(response.text) == {'auth': 'Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM='}61+ assert json.loads(response.text) == {62+ "auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="63+ }64 65 66 def test_custom_auth():67 url = "https://example.org/"68 69 def auth(request):65- request.headers['Authorization'] = 'Token 123'70+ request.headers["Authorization"] = "Token 123"71 return request72 73 with Client(dispatch=MockDispatch()) as client:74 response = client.get(url, auth=auth)75 76 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 lines53 await send({"type": "http.response.body", "body": b"Hello, world!"})54 55 56 async def echo_body(scope, receive, send):57- body = b''57+ body = b""58 more_body = True59 60 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)64 65 await send(66 {67 "type": "http.response.start",44 unmodified lines