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
50 changes: 49 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dockerflow = "2022.1.0"
Jinja2 = "^3.0.3"
pydantic-yaml = {extras = ["pyyaml","ruamel"], version = "^0.6.1"}
sentry-sdk = "^1.5.7"
orjson = "^3.7.7"


[tool.poetry.dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions src/app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sentry_sdk
import uvicorn # type: ignore
from fastapi import Body, Depends, FastAPI, Request
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.responses import HTMLResponse, ORJSONResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
Expand Down Expand Up @@ -97,9 +97,9 @@ def bugzilla_webhook(
"""API endpoint that Bugzilla Webhook Events request"""
try:
result = execute_action(request, actions, settings)
return JSONResponse(content=result, status_code=200)
return ORJSONResponse(content=result, status_code=200)
except IgnoreInvalidRequestError as exception:
return JSONResponse(content={"error": str(exception)}, status_code=200)
return ORJSONResponse(content={"error": str(exception)}, status_code=200)


@app.get("/whiteboard_tags/")
Expand Down
4 changes: 2 additions & 2 deletions src/app/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Dict

from fastapi import APIRouter, Depends, Request
from fastapi.responses import JSONResponse
from fastapi.responses import ORJSONResponse

from src.app import environment
from src.jbi.services import jbi_service_health_map
Expand All @@ -20,7 +20,7 @@ def heartbeat(request: Request, settings: environment.Settings):
if not health.get("up"):
status_code = 503

return JSONResponse(content=data, status_code=status_code)
return ORJSONResponse(content=data, status_code=status_code)


@api_router.get("/__heartbeat__")
Expand Down
20 changes: 18 additions & 2 deletions tests/unit/app/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from unittest import mock

import pytest
from datetime import datetime
from fastapi.testclient import TestClient

from src.app.api import app
Expand Down Expand Up @@ -96,8 +97,23 @@ def test_webhook_is_200_if_action_succeeds(
mocked_jira,
mocked_bugzilla,
):
mocked_bugzilla().update_bugs.return_value = {}
mocked_jira().create_or_update_issue_remote_links.return_value = {}
mocked_bugzilla().update_bugs.return_value = {
"bugs": [
{
"changes": {
"see_also": {
"added": "https://mozilla.atlassian.net/browse/JBI-1922",
"removed": "",
}
},
"last_change_time": datetime.now(),
}
]
}
mocked_jira().create_or_update_issue_remote_links.return_value = {
"id": 18936,
"self": "https://mozilla.atlassian.net/rest/api/2/issue/JBI-1922/remotelink/18936",
}

with TestClient(app) as anon_client:
response = anon_client.post(
Expand Down