• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / fx-private-relay / 3f809551-6712-425b-b278-bf1cf7d34ed4

19 Sep 2025 06:01PM UTC coverage: 88.138% (-0.7%) from 88.863%
3f809551-6712-425b-b278-bf1cf7d34ed4

Pull #5885

circleci

joeherm
fix(twilio): Add error handling for flaky Twilio calls
Pull Request #5885: fix(twilio): Add error handling for erroring Twilio calls

2925 of 3955 branches covered (73.96%)

Branch coverage included in aggregate %.

42 of 42 new or added lines in 2 files covered. (100.0%)

116 existing lines in 7 files now uncovered.

18199 of 20012 relevant lines covered (90.94%)

11.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.58
/api/urls.py
1
from django.conf import settings
1✔
2
from django.urls import URLPattern, URLResolver, include, path, register_converter
1✔
3

4
from drf_spectacular.views import (
1✔
5
    SpectacularAPIView,
6
    SpectacularRedocView,
7
    SpectacularSwaggerSplitView,
8
)
9
from rest_framework import routers
1✔
10

11
from privaterelay.utils import enable_if_setting
1✔
12

13
from .views.emails import (
1✔
14
    DomainAddressViewSet,
15
    RelayAddressViewSet,
16
    first_forwarded_email,
17
)
18
from .views.privaterelay import (
1✔
19
    FlagViewSet,
20
    ProfileViewSet,
21
    UserViewSet,
22
    report_webcompat_issue,
23
    runtime_data,
24
    terms_accepted_user,
25
)
26

27

28
class SwaggerFormatConverter:
1✔
29
    regex = r"\.(json|yaml)"
1✔
30

31
    def to_python(self, value):
1✔
32
        return value
×
33

34
    def to_url(self, value):
1✔
35
        return value
×
36

37

38
register_converter(SwaggerFormatConverter, "swagger_format")
1✔
39

40

41
api_router = routers.DefaultRouter()
1✔
42
api_router.register(r"domainaddresses", DomainAddressViewSet, "domainaddress")
1✔
43
api_router.register(r"relayaddresses", RelayAddressViewSet, "relayaddress")
1✔
44
api_router.register(r"profiles", ProfileViewSet, "profiles")
1✔
45
api_router.register(r"users", UserViewSet, "user")
1✔
46
api_router.register(r"flags", FlagViewSet, "flag")
1✔
47

48

49
urlpatterns: list[URLPattern | URLResolver] = [
1✔
50
    path(
51
        "v1/runtime_data",
52
        runtime_data,
53
        name="runtime_data_deprecate_after_updating_clients",
54
    ),
55
    path("v1/runtime_data/", runtime_data, name="runtime_data"),
56
    path(
57
        "v1/report_webcompat_issue",
58
        report_webcompat_issue,
59
        name="report_webcompat_issue_deprecate_after_updating_clients",
60
    ),
61
    path(
62
        "v1/report_webcompat_issue/",
63
        report_webcompat_issue,
64
        name="report_webcompat_issue",
65
    ),
66
    path(
67
        "v1/terms-accepted-user/",
68
        terms_accepted_user,
69
        name="terms_accepted_user",
70
    ),
71
    path(
72
        "v1/schema/",
73
        enable_if_setting("API_DOCS_ENABLED")(SpectacularAPIView.as_view()),
74
        name="schema",
75
    ),
76
    path(
77
        "v1/docs/",
78
        enable_if_setting("API_DOCS_ENABLED")(
79
            SpectacularSwaggerSplitView.as_view(url_name="schema")
80
        ),
81
        name="schema-swagger-ui",
82
    ),
83
    path(
84
        "v1/docs/redoc/",
85
        enable_if_setting("API_DOCS_ENABLED")(
86
            SpectacularRedocView.as_view(url_name="schema")
87
        ),
88
        name="schema-redoc-ui",
89
    ),
90
    path(
91
        "v1/first-forwarded-email/",
92
        first_forwarded_email,
93
        name="first_forwarded_email",
94
    ),
95
]
96

97
if settings.PHONES_ENABLED:
1!
98
    from .views.phones import (
1✔
99
        InboundContactViewSet,
100
        RealPhoneViewSet,
101
        RelayNumberViewSet,
102
        inbound_call,
103
        inbound_sms,
104
        list_messages,
105
        outbound_call,
106
        outbound_sms,
107
        resend_welcome_sms,
108
        sms_status,
109
        vCard,
110
        voice_status,
111
    )
112

113
if settings.PHONES_ENABLED:
1!
114
    api_router.register(r"realphone", RealPhoneViewSet, "real_phone")
1✔
115
    api_router.register(r"relaynumber", RelayNumberViewSet, "relay_number")
1✔
116
    api_router.register(r"inboundcontact", InboundContactViewSet, "inbound_contact")
1✔
117
    urlpatterns += [
1✔
118
        # TODO: Update Twilio webhooks to versions with trailing slashes,
119
        #       then remove versions without trailing slashes (Django's
120
        #       APPEND_SLASH option will then make those redirect).
121
        path(
122
            "v1/inbound_sms",
123
            inbound_sms,
124
            name="inbound_sms_deprecate_after_updating_clients",
125
        ),
126
        path("v1/inbound_sms/", inbound_sms, name="inbound_sms"),
127
        path(
128
            "v1/inbound_call",
129
            inbound_call,
130
            name="inbound_call_deprecate_after_updating_clients",
131
        ),
132
        path("v1/inbound_call/", inbound_call, name="inbound_call"),
133
        path(
134
            "v1/voice_status",
135
            voice_status,
136
            name="voice_status_deprecate_after_updating_clients",
137
        ),
138
        path("v1/voice_status/", voice_status, name="voice_status"),
139
        path("v1/call/", outbound_call, name="outbound_call"),
140
        path("v1/messages/", list_messages, name="list_messages"),
141
        path("v1/message/", outbound_sms, name="outbound_sms"),
142
        path(
143
            "v1/sms_status",
144
            sms_status,
145
            name="sms_status_deprecate_after_updating_clients",
146
        ),
147
        path("v1/sms_status/", sms_status, name="sms_status"),
148
        path(
149
            "v1/vCard/<str:lookup_key>",
150
            vCard,
151
            name="vCard_deprecate_after_updating_clients",
152
        ),
153
        path("v1/vCard/<str:lookup_key>/", vCard, name="vCard"),
154
        path(
155
            "v1/realphone/resend_welcome_sms",
156
            resend_welcome_sms,
157
            name="resend_welcome_sms_deprecate_after_updating_clients",
158
        ),
159
        path(
160
            "v1/realphone/resend_welcome_sms/",
161
            resend_welcome_sms,
162
            name="resend_welcome_sms",
163
        ),
164
    ]
165

166

167
if settings.PHONES_ENABLED and settings.IQ_ENABLED:
1!
UNCOV
168
    from .views.phones import inbound_sms_iq
×
169

UNCOV
170
    urlpatterns += [
×
171
        path(
172
            "v1/inbound_sms_iq/",
173
            enable_if_setting("IQ_ENABLED")(inbound_sms_iq),
174
            name="inbound_sms",
175
        ),
176
    ]
177

178

179
urlpatterns += [
1✔
180
    path("v1/", include(api_router.urls)),
181
]
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc