Skip to content

Commit

Permalink
feat: added test for course api v2
Browse files Browse the repository at this point in the history
  • Loading branch information
AhtishamShahid committed May 21, 2024
1 parent 371b71e commit 46f3457
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lms/djangoapps/discussion/rest_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _format_datetime(dt):
{"code": reason_code, "label": label}
for (reason_code, label) in CLOSE_REASON_CODES.items()
],
'show_discussions': discussion_tab and discussion_tab.is_enabled(course, request.user),
'show_discussions': bool(discussion_tab and discussion_tab.is_enabled(course, request.user)),
}


Expand Down
4 changes: 4 additions & 0 deletions lms/djangoapps/discussion/rest_api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ def test_discussions_disabled(self):
with pytest.raises(DiscussionDisabledError):
get_course(self.request, _discussion_disabled_course_for(self.user).id)

def test_discussions_disabled_v2(self):
data = get_course(self.request, _discussion_disabled_course_for(self.user).id, False)
assert data['show_discussions'] is False

def test_basic(self):
assert get_course(self.request, self.course.id) == {
'id': str(self.course.id),
Expand Down

0 comments on commit 46f3457

Please sign in to comment.