Skip to content

Commit 900d31f

Browse files
authored
Remove support for user_agent, removing unneeded i/o (#1093)
1 parent d001e34 commit 900d31f

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

src/adguardhome/adguardhome.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import asyncio
66
import json
77
import socket
8-
from importlib import metadata
98
from typing import Any, Mapping, Self
109

1110
import aiohttp
@@ -35,7 +34,6 @@ def __init__( # noqa: PLR0913
3534
request_timeout: int = 10,
3635
session: aiohttp.client.ClientSession | None = None,
3736
tls: bool = False,
38-
user_agent: str | None = None,
3937
username: str | None = None,
4038
verify_ssl: bool = True,
4139
) -> None:
@@ -53,7 +51,6 @@ def __init__( # noqa: PLR0913
5351
request_timeout: Max timeout to wait for a response from the API.
5452
session: Optional, shared, aiohttp client session.
5553
tls: True, when TLS/SSL should be used.
56-
user_agent: Defaults to PythonAdGuardHome/<version>.
5754
username: Username for HTTP auth, if enabled.
5855
verify_ssl: Can be set to false, when TLS with self-signed cert is used.
5956
@@ -69,11 +66,6 @@ def __init__( # noqa: PLR0913
6966
self.tls = tls
7067
self.username = username
7168
self.verify_ssl = verify_ssl
72-
self.user_agent = user_agent
73-
74-
if user_agent is None:
75-
version = metadata.version(__package__)
76-
self.user_agent = f"PythonAdGuardHome/{version}"
7769

7870
if self.base_path[-1] != "/":
7971
self.base_path += "/"
@@ -130,7 +122,6 @@ async def request( # noqa: PLR0913
130122
auth = aiohttp.BasicAuth(self.username, self.password)
131123

132124
headers = {
133-
"User-Agent": self.user_agent,
134125
"Accept": "application/json, text/plain, */*",
135126
}
136127

tests/test_adguardhome.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -122,43 +122,6 @@ async def test_request_base_path(aresponses: ResponsesMockServer) -> None:
122122
assert response == {"message": "OMG PUPPIES!"}
123123

124124

125-
async def test_request_user_agent(aresponses: ResponsesMockServer) -> None:
126-
"""Test AdGuard Home client sending correct user agent headers."""
127-
128-
# Handle to run asserts on request in
129-
async def response_handler(request: aiohttp.ClientResponse) -> Response:
130-
"""Response handler for this test."""
131-
assert request.headers["User-Agent"] == "PythonAdGuardHome/0.0.0"
132-
return aresponses.Response(text="TEDDYBEAR", status=200)
133-
134-
aresponses.add("example.com:3000", "/", "GET", response_handler)
135-
136-
async with aiohttp.ClientSession() as session:
137-
adguard = AdGuardHome("example.com", base_path="/", session=session)
138-
await adguard.request("/")
139-
140-
141-
async def test_request_custom_user_agent(aresponses: ResponsesMockServer) -> None:
142-
"""Test AdGuard Home client sending correct user agent headers."""
143-
144-
# Handle to run asserts on request in
145-
async def response_handler(request: aiohttp.ClientResponse) -> Response:
146-
"""Response handler for this test."""
147-
assert request.headers["User-Agent"] == "LoremIpsum/1.0"
148-
return aresponses.Response(text="TEDDYBEAR", status=200)
149-
150-
aresponses.add("example.com:3000", "/", "GET", response_handler)
151-
152-
async with aiohttp.ClientSession() as session:
153-
adguard = AdGuardHome(
154-
"example.com",
155-
base_path="/",
156-
session=session,
157-
user_agent="LoremIpsum/1.0",
158-
)
159-
await adguard.request("/")
160-
161-
162125
async def test_timeout(aresponses: ResponsesMockServer) -> None:
163126
"""Test request timeout from AdGuard Home."""
164127

0 commit comments

Comments
 (0)