Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sample setup for environmental variables

ALLOWED_ORIGINS=https://github.com,http://127.0.0.1:8000,http://0.0.0.0:8000,http://localhost:8000,https://ping.telex.im
ALLOWED_HOSTS=github.com,127.0.0.1,0.0.0.0,localhost,ping.telex.im
ALLOWED_ORIGINS=https://github.com,http://127.0.0.1:8000,http://0.0.0.0:8000,http://localhost:8000,https://ping.telex.im,http://test
ALLOWED_HOSTS=github.com,127.0.0.1,0.0.0.0,localhost,ping.telex.im,test
HOST=0.0.0.0
PORT=8000
RELOAD_VALUE=True
Expand Down
5 changes: 5 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from fastapi.testclient import TestClient

from main import app

client = TestClient(app, base_url="http://test/api/v1")
27 changes: 27 additions & 0 deletions tests/test_github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from tests import client
import json


def test_send_to_telex_success():
response = client.post(
"/webhook/github/{telex_channel_id}", # Replace with an existing channel ID to receive messages
json={
"pusher": {"name": "test"},
"commits": [
{"key": "value"},
],
},
)
assert response.status_code == 200
response_data = json.loads(response.content.decode())
assert response_data["data"]["status"] == "success"
assert response_data["data"]["status_code"] == 202


def test_send_to_telex_failure():
response = client.post(
"/webhook/github/{telex_channel_id}", json={"pusher": {"name": "test"}}
)
assert response.status_code == 422
response_data = json.loads(response.content.decode())
assert "commits" in response_data["detail"][0]["loc"]