test_classes: Give useful error when using /json/ URLs wrong.

This commit is contained in:
Tim Abbott
2025-10-03 13:59:14 -07:00
parent 981fd35288
commit 9361a3cffe

View File

@@ -1074,6 +1074,7 @@ Output:
def api_get(
self, user: UserProfile, url: str, info: Mapping[str, Any] = {}, **extra: str
) -> "TestHttpResponse":
assert not url.startswith("/json/"), "Invalid URL for API authentication"
extra["HTTP_AUTHORIZATION"] = self.encode_user(user)
return self.client_get(
url,
@@ -1096,6 +1097,7 @@ Output:
intentionally_undocumented: bool = False,
**extra: str,
) -> "TestHttpResponse":
assert not url.startswith("/json/"), "Invalid URL for API authentication"
extra["HTTP_AUTHORIZATION"] = self.encode_user(user)
return self.client_post(
url,
@@ -1112,6 +1114,7 @@ Output:
def api_patch(
self, user: UserProfile, url: str, info: Mapping[str, Any] = {}, **extra: str
) -> "TestHttpResponse":
assert not url.startswith("/json/"), "Invalid URL for API authentication"
extra["HTTP_AUTHORIZATION"] = self.encode_user(user)
return self.client_patch(
url,
@@ -1128,6 +1131,7 @@ Output:
def api_delete(
self, user: UserProfile, url: str, info: Mapping[str, Any] = {}, **extra: str
) -> "TestHttpResponse":
assert not url.startswith("/json/"), "Invalid URL for API authentication"
extra["HTTP_AUTHORIZATION"] = self.encode_user(user)
return self.client_delete(
url,