# What this PR does
- update `make test` to always use `settings.ci-test`. Right now it will
use whatever the value of `DJANGO_SETTINGS_MODULE` is in
`./dev/.env.dev`, which causes ~45 tests to fail
- Fix several Python warnings that we see when running the tests
```bash
RemovedInDjango40Warning: The providing_args argument is deprecated. As it is purely documentational, it has no replacement. If you rely on this argument as documentation, you can move the text to a code comment or docstring.
alert_create_signal = django.dispatch.Signal(
```
```bash
PytestCollectionWarning: cannot collect test class 'TestOnlyBackend' because it has a __init__ constructor (from: apps/api/tests/test_alert_receive_channel_template.py)
class TestOnlyBackend(BaseMessagingBackend):
```
```bash
DeprecationWarning: The parameter 'use_aliases' in emoji.emojize() is deprecated and will be removed in version 2.0.0. Use language='alias' instead.
To hide this warning, pin/downgrade the package to 'emoji~=1.6.3'
return emoji.emojize(self.verbal_name, use_aliases=True)
```
```bash
DateTimeField CustomOnCallShift.start received a naive datetime (2023-06-01 12:53:12) while time zone support is active.
warnings.warn("DateTimeField %s received a naive datetime (%s)"
```
```bash
apps/twilioapp/tests/test_phone_calls.py::test_resolve_by_phone
/etc/app/apps/twilioapp/tests/test_phone_calls.py:173: DeprecationWarning: The 'text' argument to find()-type methods is deprecated. Use 'string' instead.
content = BeautifulSoup(content, features="html.parser").findAll(text=True)
```
```bash
apps/twilioapp/tests/test_phone_calls.py::test_resolve_by_phone
apps/twilioapp/tests/test_phone_calls.py::test_wrong_pressed_digit
/usr/local/lib/python3.11/site-packages/bs4/builder/__init__.py:545: XMLParsedAsHTMLWarning: It looks like you're parsing an XML document using an HTML parser. If this really is an HTML document (maybe it's XHTML?), you can ignore or filter this warning. If it's XML, you should know that using an XML parser will be more reliable. To parse this document as XML, make sure you have the lxml package installed, and pass the keyword argument `features="xml"` into the BeautifulSoup constructor.
```
```bash
apps/twilioapp/tests/test_phone_calls.py::test_forbidden_requests
/usr/local/lib/python3.11/site-packages/social_django/urls.py:15: RemovedInDjango40Warning: django.conf.urls.url() is deprecated in favor of django.urls.re_path().
url(r'^login/(?P<backend>[^/]+){0}$'.format(extra), views.auth,
```
```bash
apps/twilioapp/tests/test_phone_calls.py: 66 warnings
/usr/local/lib/python3.11/site-packages/debug_toolbar/utils.py:255: DeprecationWarning: currentThread() is deprecated, use current_thread() instead
thread = threading.currentThread()
```
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
119 lines
6.3 KiB
Python
119 lines
6.3 KiB
Python
from django.urls import include, path, re_path
|
|
|
|
from common.api_helpers.optional_slash_router import OptionalSlashRouter, optional_slash_path
|
|
|
|
from .views import UserNotificationPolicyView, auth
|
|
from .views.alert_group import AlertGroupView
|
|
from .views.alert_receive_channel import AlertReceiveChannelView
|
|
from .views.alert_receive_channel_template import AlertReceiveChannelTemplateView
|
|
from .views.alerts import AlertDetailView
|
|
from .views.channel_filter import ChannelFilterView
|
|
from .views.custom_button import CustomButtonView
|
|
from .views.escalation_chain import EscalationChainViewSet
|
|
from .views.escalation_policy import EscalationPolicyView
|
|
from .views.features import FeaturesAPIView
|
|
from .views.gitops import TerraformGitOpsView, TerraformStateView
|
|
from .views.integration_heartbeat import IntegrationHeartBeatView
|
|
from .views.live_setting import LiveSettingViewSet
|
|
from .views.maintenance import MaintenanceAPIView, MaintenanceStartAPIView, MaintenanceStopAPIView
|
|
from .views.on_call_shifts import OnCallShiftView
|
|
from .views.organization import (
|
|
CurrentOrganizationView,
|
|
GetChannelVerificationCode,
|
|
GetTelegramVerificationCode,
|
|
SetGeneralChannel,
|
|
)
|
|
from .views.paging import DirectPagingAPIView
|
|
from .views.preview_template_options import PreviewTemplateOptionsView
|
|
from .views.public_api_tokens import PublicApiTokenView
|
|
from .views.resolution_note import ResolutionNoteView
|
|
from .views.route_regex_debugger import RouteRegexDebuggerView
|
|
from .views.schedule import ScheduleView
|
|
from .views.slack_channel import SlackChannelView
|
|
from .views.slack_team_settings import (
|
|
AcknowledgeReminderOptionsAPIView,
|
|
SlackTeamSettingsAPIView,
|
|
UnAcknowledgeTimeoutOptionsAPIView,
|
|
)
|
|
from .views.subscription import SubscriptionView
|
|
from .views.team import TeamViewSet
|
|
from .views.telegram_channels import TelegramChannelViewSet
|
|
from .views.user import CurrentUserView, UserView
|
|
from .views.user_group import UserGroupViewSet
|
|
from .views.webhooks import WebhooksView
|
|
|
|
app_name = "api-internal"
|
|
|
|
router = OptionalSlashRouter()
|
|
router.register(r"users", UserView, basename="user")
|
|
router.register(r"teams", TeamViewSet, basename="team")
|
|
router.register(r"alertgroups", AlertGroupView, basename="alertgroup")
|
|
router.register(r"notification_policies", UserNotificationPolicyView, basename="notification_policy")
|
|
router.register(r"escalation_policies", EscalationPolicyView, basename="escalation_policy")
|
|
router.register(r"escalation_chains", EscalationChainViewSet, basename="escalation_chain")
|
|
router.register(r"alert_receive_channels", AlertReceiveChannelView, basename="alert_receive_channel")
|
|
router.register(
|
|
r"alert_receive_channel_templates", AlertReceiveChannelTemplateView, basename="alert_receive_channel_template"
|
|
)
|
|
router.register(r"channel_filters", ChannelFilterView, basename="channel_filter")
|
|
router.register(r"schedules", ScheduleView, basename="schedule")
|
|
router.register(r"custom_buttons", CustomButtonView, basename="custom_button")
|
|
router.register(r"webhooks", WebhooksView, basename="webhooks")
|
|
router.register(r"resolution_notes", ResolutionNoteView, basename="resolution_note")
|
|
router.register(r"telegram_channels", TelegramChannelViewSet, basename="telegram_channel")
|
|
router.register(r"slack_channels", SlackChannelView, basename="slack_channel")
|
|
router.register(r"user_groups", UserGroupViewSet, basename="user_group")
|
|
router.register(r"heartbeats", IntegrationHeartBeatView, basename="integration_heartbeat")
|
|
router.register(r"tokens", PublicApiTokenView, basename="api_token")
|
|
router.register(r"live_settings", LiveSettingViewSet, basename="live_settings")
|
|
router.register(r"oncall_shifts", OnCallShiftView, basename="oncall_shifts")
|
|
|
|
urlpatterns = [
|
|
path("", include(router.urls)),
|
|
optional_slash_path("user", CurrentUserView.as_view(), name="api-user"),
|
|
optional_slash_path("set_general_channel", SetGeneralChannel.as_view(), name="api-set-general-log-channel"),
|
|
optional_slash_path("current_team", CurrentOrganizationView.as_view(), name="api-current-team"),
|
|
optional_slash_path(
|
|
"current_team/get_telegram_verification_code",
|
|
GetTelegramVerificationCode.as_view(),
|
|
name="api-get-telegram-verification-code",
|
|
),
|
|
optional_slash_path(
|
|
"current_team/get_channel_verification_code",
|
|
GetChannelVerificationCode.as_view(),
|
|
name="api-get-channel-verification-code",
|
|
),
|
|
optional_slash_path("current_subscription", SubscriptionView.as_view(), name="subscription"),
|
|
optional_slash_path("terraform_file", TerraformGitOpsView.as_view(), name="terraform_file"),
|
|
optional_slash_path("terraform_imports", TerraformStateView.as_view(), name="terraform_imports"),
|
|
optional_slash_path("maintenance", MaintenanceAPIView.as_view(), name="maintenance"),
|
|
optional_slash_path("start_maintenance", MaintenanceStartAPIView.as_view(), name="start_maintenance"),
|
|
optional_slash_path("stop_maintenance", MaintenanceStopAPIView.as_view(), name="stop_maintenance"),
|
|
optional_slash_path("slack_settings", SlackTeamSettingsAPIView.as_view(), name="slack-settings"),
|
|
optional_slash_path(
|
|
"slack_settings/acknowledge_remind_options",
|
|
AcknowledgeReminderOptionsAPIView.as_view(),
|
|
name="acknowledge-reminder-options",
|
|
),
|
|
optional_slash_path(
|
|
"slack_settings/unacknowledge_timeout_options",
|
|
UnAcknowledgeTimeoutOptionsAPIView.as_view(),
|
|
name="unacknowledge-timeout-options",
|
|
),
|
|
optional_slash_path("features", FeaturesAPIView.as_view(), name="features"),
|
|
optional_slash_path(
|
|
"preview_template_options", PreviewTemplateOptionsView.as_view(), name="preview_template_options"
|
|
),
|
|
optional_slash_path("route_regex_debugger", RouteRegexDebuggerView.as_view(), name="route_regex_debugger"),
|
|
re_path(r"^alerts/(?P<id>\w+)/?$", AlertDetailView.as_view(), name="alerts-detail"),
|
|
optional_slash_path("direct_paging", DirectPagingAPIView.as_view(), name="direct_paging"),
|
|
]
|
|
|
|
urlpatterns += [
|
|
# For some reason frontend is using url without / at the end. Hacking here to avoid 301's :(
|
|
path(r"login/<backend>", auth.overridden_login_slack_auth, name="slack-auth-with-no-slash"),
|
|
path(r"login/<backend>/", auth.overridden_login_slack_auth, name="slack-auth"),
|
|
path(r"complete/<backend>/", auth.overridden_complete_slack_auth, name="complete-slack-auth"),
|
|
]
|
|
|
|
urlpatterns += router.urls
|