@@ -18,13 +18,29 @@ def test_list_notifications_authenticated(
1818 response = client .get (url )
1919
2020 assert response .status_code == 200
21- assert len (response .data ) == 1
22- assert response .data [0 ]["title" ] == (
21+ assert response .data ["count" ] == 1
22+
23+ api_data = response .data ["results" ]
24+ assert api_data [0 ]["title" ] == (
2325 "CVE-2025-0001 was automatically matched to packages you subscribed to"
2426 )
25- assert response .data [0 ]["is_read" ] is False
26- assert "id" in response .data [0 ]
27- assert "created_at" in response .data [0 ]
27+ assert api_data [0 ]["is_read" ] is False
28+ assert "id" in api_data [0 ]
29+ assert "created_at" in api_data [0 ]
30+
31+
32+ def test_list_notifications_are_paginated (
33+ user : User ,
34+ client : APIClient ,
35+ make_maintainer_notification : Callable [..., list [Notification ]],
36+ ):
37+ make_maintainer_notification (user )
38+ url = reverse ("notification-list" )
39+
40+ response = client .get (url )
41+ assert "previous" in response .data
42+ assert "next" in response .data
43+ assert "count" in response .data
2844
2945
3046def test_list_notifications_excludes_other_users_notifications (
@@ -38,7 +54,7 @@ def test_list_notifications_excludes_other_users_notifications(
3854 response = client .get (url )
3955
4056 assert response .status_code == 200
41- assert len ( response .data ) == 0
57+ assert response .data [ "count" ] == 0
4258
4359
4460def test_list_notifications_unauthenticated (
@@ -61,7 +77,7 @@ def test_list_notifications_empty(
6177 response = client .get (url )
6278
6379 assert response .status_code == 200
64- assert len ( response .data ) == 0
80+ assert response .data [ "count" ] == 0
6581
6682
6783def test_list_notifications_includes_text_notifications (
@@ -74,9 +90,11 @@ def test_list_notifications_includes_text_notifications(
7490 response = client .get (url )
7591
7692 assert response .status_code == 200
77- assert len (response .data ) == 1
78- assert response .data [0 ]["title" ] == "Hello"
79- assert response .data [0 ]["is_read" ] is False
93+ assert response .data ["count" ] == 1
94+
95+ api_data = response .data ["results" ]
96+ assert api_data [0 ]["title" ] == "Hello"
97+ assert api_data [0 ]["is_read" ] is False
8098
8199
82100def test_list_notifications_shows_both_types (
@@ -91,4 +109,4 @@ def test_list_notifications_shows_both_types(
91109 response = client .get (url )
92110
93111 assert response .status_code == 200
94- assert len ( response .data ) == 2
112+ assert response .data [ "count" ] == 2
0 commit comments