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

mozilla / fx-private-relay / b2e067fe-ce4e-4099-9bef-07b368e99782

15 Apr 2024 04:18PM CUT coverage: 75.544% (+0.002%) from 75.542%
b2e067fe-ce4e-4099-9bef-07b368e99782

push

circleci

jwhitlock
Enable pyupgrade, fix issues

2443 of 3405 branches covered (71.75%)

Branch coverage included in aggregate %.

56 of 59 new or added lines in 14 files covered. (94.92%)

234 existing lines in 24 files now uncovered.

6793 of 8821 relevant lines covered (77.01%)

20.04 hits per line

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

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

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

11
from privaterelay.utils import enable_if_setting
1✔
12

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

25

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

29
    def to_python(self, value):
1✔
UNCOV
30
        return value
×
31

32
    def to_url(self, value):
1✔
UNCOV
33
        return value
×
34

35

36
register_converter(SwaggerFormatConverter, "swagger_format")
1✔
37

38

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

46

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

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

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

164

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

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

176

177
urlpatterns += [
1✔
178
    path("v1/", include(api_router.urls)),
179
]
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