Skip to content

Commit

Permalink
test: api test
Browse files Browse the repository at this point in the history
  • Loading branch information
suchencjusz committed Sep 8, 2024
1 parent a4f25c6 commit 9cdd5ad
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 368 deletions.
4 changes: 2 additions & 2 deletions src/filman_server/database/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ def get_user(


def get_users(db: Session):

# link also filmweb_id from filmweb mapping
return db.query(models.User).all()


Expand Down Expand Up @@ -182,6 +180,8 @@ def delete_guild(db: Session, discord_guild_id: int):

return db_guild

def get_guilds(db: Session):
return db.query(models.DiscordGuilds).all()

#
# FILMWEB MOVIES
Expand Down
17 changes: 9 additions & 8 deletions src/filman_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

models.Base.metadata.create_all(bind=engine)

sentry_sdk.init(
dsn="https://e90f28bf688cd7f8a1f8dcbc3586d359@o4506423653105664.ingest.sentry.io/4506423687774208",
enable_tracing=True,
integrations=[
StarletteIntegration(transaction_style="endpoint"),
FastApiIntegration(transaction_style="endpoint"),
],
)
# sentry_sdk.init(
# dsn="https://e90f28bf688cd7f8a1f8dcbc3586d359@o4506423653105664.ingest.sentry.io/4506423687774208",
# enable_tracing=False, # true
# integrations=[
# StarletteIntegration(transaction_style="endpoint"),
# FastApiIntegration(transaction_style="endpoint"),
# ],

# )

app = FastAPI()

Expand Down
18 changes: 17 additions & 1 deletion src/filman_server/routes/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,26 @@
discord_router = APIRouter(prefix="/discord", tags=["discord"])


@discord_router.post("/configure/guild", response_model=schemas.DiscordGuilds)
@discord_router.post(
"/configure/guild",
response_model=schemas.DiscordGuilds,
summary="Configure a guild",
description="Configure a discord guild, this endpoint is connecting a guild text channel to guild id (is used for managing where notifications are sent)",
)
async def configure_guild(guild: schemas.DiscordGuildsCreate, db: Session = Depends(get_db)):
try:
db_guild = crud.set_guild(db, guild)
return db_guild
except IntegrityError:
raise HTTPException(status_code=400, detail="Guild already exists")


@discord_router.get(
"/guilds",
response_model=List[schemas.DiscordGuilds],
summary="Get all guilds",
description="Get all guilds that are configured in the database",
)
async def get_guilds(db: Session = Depends(get_db)):
guilds = crud.get_guilds(db)
return guilds
Loading

0 comments on commit 9cdd5ad

Please sign in to comment.