Skip to content

Commit 3c04d17

Browse files
committed
add a basic test client for posting test webhooks
1 parent 92d35e5 commit 3c04d17

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-0
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ migrations:
2020

2121
test:
2222
$(TEST_CMD) -s -vv
23+
24+
25+
client/send_test_webhook:
26+
uv run client/send_test_webhook.py

client/send_test_webhook.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
from pprint import pprint as pp
3+
4+
import httpx
5+
6+
INTERNAL_WEBHOOK_TOKEN = os.environ["INTERNAL_WEBHOOK_TOKEN"]
7+
8+
9+
def send_test_webhook():
10+
url = "http://localhost:4672/webhook/internal/"
11+
response = httpx.post(
12+
url,
13+
json={"event": "test webhook"},
14+
headers={"Authorization": INTERNAL_WEBHOOK_TOKEN},
15+
)
16+
17+
print(response)
18+
print(response.content)
19+
# pp(response.json())
20+
21+
22+
if __name__ == "__main__":
23+
send_test_webhook()

intbot/intbot/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@
121121
}
122122
}
123123

124+
WEBHOOK_INTERNAL_TOKEN = "dev-token"
125+
124126
elif DJANGO_ENV == "test":
125127
DEBUG = True
126128
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ dependencies = [
1414
"pytest>=8.3.4",
1515
"pytest-django>=4.9.0",
1616
"django-extensions>=3.2.3",
17+
"httpx>=0.28.1",
1718
]

uv.lock

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)