-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_main.py
More file actions
71 lines (62 loc) · 2.3 KB
/
test_main.py
File metadata and controls
71 lines (62 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import pytest
from fastapi.testclient import TestClient
from fastapi import HTTPException
from unittest.mock import patch
import httpx
import re
import os
from main import app
client = TestClient(app)
GITHUB_API_URL = "https://api.github.com/user/following/"
headers = {
"Authorization": f"token {os.getenv('GITHUB_TOKEN')}",
"Accept": "application/vnd.github.v3+json"
}
def test_toggle_follow_github_user():
test_payload = {
"message": "Starred by: example_user"
}
with patch("httpx.AsyncClient.get") as mock_get, patch("httpx.AsyncClient.put") as mock_put, patch("httpx.AsyncClient.delete") as mock_delete:
mock_get.return_value.status_code = 404
mock_put.return_value.status_code = 204
response = client.post("/webhook", json=test_payload)
assert response.status_code == 200
assert response.json() == {"message": "Successfully followed example_user!"}
def test_integration_config():
response = client.get('/integration.json')
assert response.status_code == 200
assert response.json() == {
"data": {
"date": {
"created_at": "2025-02-20",
"updated_at": "2025-02-20"
},
"descriptions": {
"app_name": "github-star-notifier",
"app_description": "This integration notifies my channel of a starred event on my repository",
"app_logo": "https://www.pinterest.com/pin/883690758133210277/",
"app_url": "https://p7hr5wrm-8000.uks1.devtunnels.ms",
"background_color": "#fff"
},
"is_active": True,
"integration_type": "modifier",
"integration_category": "Task Automation",
"key_features": [
"real time notification"
],
"author": "Graeyy",
"settings": [
{
"label": "event_type",
"type": "dropdown",
"required": True,
"default": "unstarred",
"options": [
"starred",
"unstarred"
]
}
],
"target_url": "https://p7hr5wrm-8000.uks1.devtunnels.ms/webhook",
}
}