Skip to content

Commit 99d7a2b

Browse files
committed
update test and view
1 parent 4701a3f commit 99d7a2b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

learning_resources/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ def get_queryset(self):
922922
"""
923923
return UserListRelationship.objects.filter(
924924
child__published=True,
925+
parent__author=self.request.user,
925926
).order_by("child", "parent")
926927

927928

learning_resources/views_userlist_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ def test_user_list_endpoint_patch(client, update_topics):
115115
@pytest.mark.parametrize("is_authenticated", [True, False])
116116
def test_user_list_endpoint_membership_get(client, user, is_authenticated):
117117
"""Test user list membership endpoint"""
118-
user_lists = factories.UserListFactory.create_batch(2, author=user)
119-
factories.UserListFactory.create()
118+
factories.UserListRelationshipFactory.create_batch(
119+
3, parent=factories.UserListFactory.create(author=user)
120+
)
121+
factories.UserListRelationshipFactory.create_batch(2)
120122

121-
relationships = UserListRelationship.objects.filter(parent__in=user_lists).order_by(
123+
relationships = UserListRelationship.objects.filter(parent__author=user).order_by(
122124
"child", "parent"
123125
)
124-
126+
assert relationships.count() == 3
125127
if is_authenticated:
126128
client.force_login(user)
127129
resp = client.get(reverse("lr:v1:userlists_api-membership"))

0 commit comments

Comments
 (0)