File tree Expand file tree Collapse file tree 7 files changed +38
-17
lines changed Expand file tree Collapse file tree 7 files changed +38
-17
lines changed Original file line number Diff line number Diff line change 1+ import os
2+ from distutils .util import strtobool
13from functools import lru_cache
24
35from pydantic import BaseSettings
46
57
68class Settings (BaseSettings ):
9+ DEBUG : bool = bool (strtobool (os .getenv ('DEBUG' , 'False' )))
10+
711 BASECAMP_ACCOUNT_ID : str = 'bc-acc-id'
812 BASECAMP_CHATBOT_KEY : str = 'bc-bot-key'
913
1014 class Config :
11- env_file = '.env'
15+ env_file = 'src/ .env'
1216
1317
1418@lru_cache ()
Original file line number Diff line number Diff line change 1+ from fastapi import FastAPI
2+
3+ from config import get_settings
4+ from sentry .api import api_router
5+
6+
7+ settings = get_settings ()
8+
9+ app = FastAPI (
10+ debug = settings .DEBUG ,
11+ )
12+
13+ app .include_router (api_router )
Original file line number Diff line number Diff line change 1- from typing import Any , Mapping
21from fastapi .requests import Request
32from fastapi .responses import Response
4- from uuid import UUID
53
6- from fastapi import FastAPI
74from fastapi import status
8- from pydantic .config import Extra
9- from pydantic .main import BaseModel
5+ from fastapi import APIRouter
106
11- app = FastAPI ()
7+ from sentry . types import Webhook
128
139
14- class Installation (BaseModel ):
15- uuid : UUID
10+ api_router = APIRouter ()
1611
1712
18- class Webhook (BaseModel , extra = Extra .allow ):
19- action : str
20- data : Mapping [str , Any ]
21- installation : Installation
22-
23-
24- @app .post ("/api/sentry/webhook" , status_code = status .HTTP_200_OK )
13+ @api_router .post ("/api/sentry/webhook" , status_code = status .HTTP_200_OK )
2514async def sentry_webhook (webhook : Webhook , request : Request ):
2615 if request .headers .get ('sentry-hook-resource' ) == 'issue' :
2716
Original file line number Diff line number Diff line change 11import pytest
22from fastapi .testclient import TestClient
3- from sentry . main import app
3+ from main import app
44from sentry .tests .request_data import event , issue
55
66
Original file line number Diff line number Diff line change 1+ from typing import Any , Mapping
2+ from uuid import UUID
3+
4+ from pydantic import BaseModel
5+ from pydantic .config import Extra
6+
7+
8+ class Installation (BaseModel ):
9+ uuid : UUID
10+
11+
12+ class Webhook (BaseModel , extra = Extra .allow ):
13+ action : str
14+ data : Mapping [str , Any ]
15+ installation : Installation
You can’t perform that action at this time.
0 commit comments