Skip to content

Commit 5f1fe32

Browse files
asmodehnAlexandre Vincent
andauthored
[fix:tests] Update urls.py to use api_views argument
Co-authored-by: Alexandre Vincent <alexandre.vincent@stellar.tc>
1 parent 17d384f commit 5f1fe32

2 files changed

Lines changed: 38 additions & 12 deletions

File tree

  • openwisp_notifications/api
  • tests/openwisp2/sample_notifications

openwisp_notifications/api/urls.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,61 @@ def get_api_urls(api_views=None):
99
if not api_views:
1010
api_views = views
1111
return [
12-
path("notification/", views.notifications_list, name="notifications_list"),
12+
path("notification/", api_views.notifications_list, name="notifications_list"),
1313
path(
1414
"notification/read/",
15-
views.notifications_read_all,
15+
api_views.notifications_read_all,
1616
name="notifications_read_all",
1717
),
1818
path(
1919
"notification/<uuid:pk>/",
20-
views.notification_detail,
20+
api_views.notification_detail,
2121
name="notification_detail",
2222
),
2323
path(
2424
"notification/<uuid:pk>/redirect/",
25-
views.notification_read_redirect,
25+
api_views.notification_read_redirect,
2626
name="notification_read_redirect",
2727
),
2828
path(
2929
"user/<uuid:user_id>/user-setting/",
30-
views.notification_setting_list,
30+
api_views.notification_setting_list,
3131
name="user_notification_setting_list",
3232
),
3333
path(
3434
"user/<uuid:user_id>/user-setting/<uuid:pk>/",
35-
views.notification_setting,
35+
api_views.notification_setting,
3636
name="user_notification_setting",
3737
),
3838
path(
3939
"user/<uuid:user_id>/organization/<uuid:organization_id>/setting/",
40-
views.user_org_notification_setting,
40+
api_views.user_org_notification_setting,
4141
name="user_org_notification_setting",
4242
),
4343
path(
4444
"notification/ignore/",
45-
views.ignore_object_notification_list,
45+
api_views.ignore_object_notification_list,
4646
name="ignore_object_notification_list",
4747
),
4848
path(
4949
"notification/ignore/<str:app_label>/<str:model_name>/<uuid:object_id>/",
50-
views.ignore_object_notification,
50+
api_views.ignore_object_notification,
5151
name="ignore_object_notification",
5252
),
5353
path(
5454
"organization/<uuid:organization_id>/setting/",
55-
views.org_notification_setting,
55+
api_views.org_notification_setting,
5656
name="org_notification_setting",
5757
),
5858
# DEPRECATED
5959
path(
6060
"user/user-setting/",
61-
views.notification_setting_list,
61+
api_views.notification_setting_list,
6262
name="notification_setting_list",
6363
),
6464
path(
6565
"user/user-setting/<uuid:pk>/",
66-
views.notification_setting,
66+
api_views.notification_setting,
6767
name="notification_setting",
6868
),
6969
]

tests/openwisp2/sample_notifications/views.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
from openwisp_notifications.api.views import (
1818
NotificationReadAllView as BaseNotificationReadAllView,
1919
)
20+
from openwisp_notifications.api.views import (
21+
NotificationReadRedirect as BaseNotificationReadRedirect,
22+
)
2023
from openwisp_notifications.api.views import (
2124
NotificationSettingListView as BaseNotificationSettingListView,
2225
)
@@ -26,6 +29,9 @@
2629
from openwisp_notifications.api.views import (
2730
OrganizationNotificationSettingView as BaseOrganizationNotificationSettingView,
2831
)
32+
from openwisp_notifications.api.views import (
33+
UserOrgNotificationSettingView as BaseUserOrgNotificationSettingView,
34+
)
2935

3036

3137
class NotificationListView(BaseNotificationListView):
@@ -53,6 +59,10 @@ class NotificationReadAllView(BaseNotificationReadAllView):
5359
pass
5460

5561

62+
class NotificationReadRedirect(BaseNotificationReadRedirect):
63+
pass
64+
65+
5666
class NotificationSettingView(BaseNotificationSettingView):
5767
"""
5868
Retrives details for a notification setting and provides
@@ -70,6 +80,10 @@ class NotificationSettingListView(BaseNotificationSettingListView):
7080
pass
7181

7282

83+
class UserOrgNotificationSettingView(BaseUserOrgNotificationSettingView):
84+
pass
85+
86+
7387
class IgnoreObjectNotificationView(BaseIgnoreObjectNotificationView):
7488
"""
7589
Retrives details for a IgnoreNotificationObject object and
@@ -94,3 +108,15 @@ class OrganizationNotificationSettingView(BaseOrganizationNotificationSettingVie
94108
"""
95109

96110
pass
111+
112+
113+
notifications_list = NotificationListView.as_view()
114+
notification_detail = NotificationDetailView.as_view()
115+
notifications_read_all = NotificationReadAllView.as_view()
116+
notification_read_redirect = NotificationReadRedirect.as_view()
117+
notification_setting_list = NotificationSettingListView.as_view()
118+
notification_setting = NotificationSettingView.as_view()
119+
user_org_notification_setting = UserOrgNotificationSettingView.as_view()
120+
org_notification_setting = OrganizationNotificationSettingView.as_view()
121+
ignore_object_notification_list = IgnoreObjectNotificationListView.as_view()
122+
ignore_object_notification = IgnoreObjectNotificationView.as_view()

0 commit comments

Comments
 (0)