Skip to content

Commit

Permalink
fix: resolve inconsistant python dependencies
Browse files Browse the repository at this point in the history
- run `make compile-requirements forum`. Error: It appears that the
Python dependencies in this PR are inconsistent: A re-run of
`make compile-requirements` produced changes.
- fix quality checks
  • Loading branch information
Muhammad Faraz Maqsood committed Sep 27, 2024
1 parent cb58346 commit 740b127
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 22 deletions.
91 changes: 77 additions & 14 deletions lms/djangoapps/discussion/django_comment_client/tests/group_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,48 @@ def test_cohorted_topic_student_with_own_group_id(self, mock_is_forum_v2_enabled
self._assert_comments_service_called_with_group_id(mock_request, self.student_cohort.id)

def test_cohorted_topic_student_with_other_group_id(self, mock_is_forum_v2_enabled, mock_request):
self.call_view(mock_is_forum_v2_enabled, mock_request, "cohorted_topic", self.student, self.moderator_cohort.id)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"cohorted_topic",
self.student,
self.moderator_cohort.id
)
self._assert_comments_service_called_with_group_id(mock_request, self.student_cohort.id)

def test_cohorted_topic_moderator_without_group_id(self, mock_is_forum_v2_enabled, mock_request):
self.call_view(mock_is_forum_v2_enabled, mock_request, "cohorted_topic", self.moderator, '', pass_group_id=False)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"cohorted_topic",
self.moderator,
'',
pass_group_id=False
)
self._assert_comments_service_called_without_group_id(mock_request)

def test_cohorted_topic_moderator_none_group_id(self, mock_is_forum_v2_enabled, mock_request):
self.call_view(mock_is_forum_v2_enabled, mock_request, "cohorted_topic", self.moderator, "")
self._assert_comments_service_called_without_group_id(mock_request)

def test_cohorted_topic_moderator_with_own_group_id(self, mock_is_forum_v2_enabled, mock_request):
self.call_view(mock_is_forum_v2_enabled, mock_request, "cohorted_topic", self.moderator, self.moderator_cohort.id)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"cohorted_topic",
self.moderator,
self.moderator_cohort.id
)
self._assert_comments_service_called_with_group_id(mock_request, self.moderator_cohort.id)

def test_cohorted_topic_moderator_with_other_group_id(self, mock_is_forum_v2_enabled, mock_request):
self.call_view(mock_is_forum_v2_enabled, mock_request, "cohorted_topic", self.moderator, self.student_cohort.id)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"cohorted_topic",
self.moderator,
self.student_cohort.id
)
self._assert_comments_service_called_with_group_id(mock_request, self.student_cohort.id)

def test_cohorted_topic_moderator_with_invalid_group_id(self, mock_is_forum_v2_enabled, mock_request):
Expand Down Expand Up @@ -132,40 +157,78 @@ def call_view(self, mock_is_forum_v2_enabled, mock_request, commentable_id, user
pass # lint-amnesty, pylint: disable=unnecessary-pass

def test_non_cohorted_topic_student_without_group_id(self, mock_is_forum_v2_enabled, mock_request):
self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.student, '', pass_group_id=False)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"non_cohorted_topic",
self.student,
'',
pass_group_id=False
)
self._assert_comments_service_called_without_group_id(mock_request)

def test_non_cohorted_topic_student_none_group_id(self, mock_is_forum_v2_enabled, mock_request):
response = self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.student, '')
self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.student, '')
self._assert_comments_service_called_without_group_id(mock_request)

def test_non_cohorted_topic_student_with_own_group_id(self, mock_is_forum_v2_enabled, mock_request):
response = self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.student, self.student_cohort.id)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"non_cohorted_topic",
self.student,
self.student_cohort.id
)
self._assert_comments_service_called_without_group_id(mock_request)

def test_non_cohorted_topic_student_with_other_group_id(self, mock_is_forum_v2_enabled, mock_request):
response = self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.student, self.moderator_cohort.id)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"non_cohorted_topic",
self.student,
self.moderator_cohort.id
)
self._assert_comments_service_called_without_group_id(mock_request)

def test_non_cohorted_topic_moderator_without_group_id(self, mock_is_forum_v2_enabled, mock_request):
response = self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.moderator, '', pass_group_id=False)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"non_cohorted_topic",
self.moderator,
"",
pass_group_id=False,
)
self._assert_comments_service_called_without_group_id(mock_request)

def test_non_cohorted_topic_moderator_none_group_id(self, mock_is_forum_v2_enabled, mock_request):
response = self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.moderator, '')
self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.moderator, '')
self._assert_comments_service_called_without_group_id(mock_request)

def test_non_cohorted_topic_moderator_with_own_group_id(self, mock_is_forum_v2_enabled, mock_request):
response = self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.moderator, self.moderator_cohort.id)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"non_cohorted_topic",
self.moderator,
self.moderator_cohort.id,
)
self._assert_comments_service_called_without_group_id(mock_request)

def test_non_cohorted_topic_moderator_with_other_group_id(self, mock_is_forum_v2_enabled, mock_request):
response = self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.moderator, self.student_cohort.id)
self.call_view(
mock_is_forum_v2_enabled,
mock_request,
"non_cohorted_topic",
self.moderator,
self.student_cohort.id,
)
self._assert_comments_service_called_without_group_id(mock_request)

def test_non_cohorted_topic_moderator_with_invalid_group_id(self, mock_is_forum_v2_enabled, mock_request):
invalid_id = self.student_cohort.id + self.moderator_cohort.id
response = self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.moderator, invalid_id)
self.call_view(mock_is_forum_v2_enabled, mock_request, "non_cohorted_topic", self.moderator, invalid_id)
self._assert_comments_service_called_without_group_id(mock_request)

def test_team_discussion_id_not_cohorted(self, mock_is_forum_v2_enabled, mock_request):
Expand All @@ -175,6 +238,6 @@ def test_team_discussion_id_not_cohorted(self, mock_is_forum_v2_enabled, mock_re
)

team.add_user(self.student)
response = self.call_view(mock_is_forum_v2_enabled, mock_request, team.discussion_topic_id, self.student, '')
self.call_view(mock_is_forum_v2_enabled, mock_request, team.discussion_topic_id, self.student, '')

self._assert_comments_service_called_without_group_id(mock_request)
1 change: 0 additions & 1 deletion lms/djangoapps/discussion/rest_api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3831,7 +3831,6 @@ def setUpClass(cls):
super().setUpClass()
cls.course = CourseFactory.create()


@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
def setUp(self):
super().setUp()
Expand Down
1 change: 1 addition & 0 deletions lms/djangoapps/discussion/rest_api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ def setUp(self):
patcher = mock.patch('lms.djangoapps.discussion.toggles.ENABLE_FORUM_V2.is_enabled', return_value=False)
patcher.start()
self.addCleanup(patcher.stop)

def test_404(self):
response = self.client.get(
reverse("course_topics", kwargs={"course_id": "non/existent/course"})
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/discussion/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ def setUp(self):
super().setUp()
self.cohorted_commentable_id = 'cohorted_topic'

def call_view(self, mock_request, commentable_id, user, group_id, pass_group_id=True):
def call_view(self, mock_request, commentable_id, user, group_id, pass_group_id=True): # pylint: disable=arguments-differ
kwargs = {'commentable_id': self.cohorted_commentable_id}
if group_id:
# avoid causing a server error when the LMS chokes attempting
Expand Down Expand Up @@ -1304,7 +1304,7 @@ def verify_group_id_not_present(profiled_user, pass_group_id, requested_cohort=s
class FollowedThreadsDiscussionGroupIdTestCase(CohortedTestCase, CohortedTopicGroupIdTestMixin): # lint-amnesty, pylint: disable=missing-class-docstring
cs_endpoint = "/subscribed_threads"

def call_view(self, mock_request, commentable_id, user, group_id, pass_group_id=True):
def call_view(self, mock_request, commentable_id, user, group_id, pass_group_id=True): # pylint: disable=arguments-differ
kwargs = {}
if group_id:
kwargs['group_id'] = group_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def retrieve(self, *args, **kwargs):
def _retrieve(self, *args, **kwargs):
response = None
if is_forum_v2_enabled(self.attributes.get("course_id")):
if self.type=="comment":
if self.type == "comment":
response = forum_api.get_parent_comment(self.attributes["id"])
if response is None:
url = self.url(action='get', params=self.attributes)
Expand Down Expand Up @@ -169,7 +169,7 @@ def save(self, params=None):
def delete(self):
response = None
if is_forum_v2_enabled(self.attributes.get("course_id")):
if self.type=="comment":
if self.type == "comment":
response = forum_api.delete_comment(self.attributes["id"])
if response is None:
url = self.url(action='delete', params=self.attributes)
Expand Down
4 changes: 3 additions & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,9 @@ multidict==6.1.0
# aiohttp
# yarl
mysqlclient==2.2.4
# via -r requirements/edx/kernel.in
# via
# -r requirements/edx/kernel.in
# forum
newrelic==9.13.0
# via
# -r requirements/edx/bundled.in
Expand Down
1 change: 1 addition & 0 deletions requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@ mysqlclient==2.2.4
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
# forum
newrelic==9.13.0
# via
# -r requirements/edx/doc.txt
Expand Down
4 changes: 3 additions & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,9 @@ multidict==6.1.0
# aiohttp
# yarl
mysqlclient==2.2.4
# via -r requirements/edx/base.txt
# via
# -r requirements/edx/base.txt
# forum
newrelic==9.13.0
# via
# -r requirements/edx/base.txt
Expand Down
4 changes: 3 additions & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,9 @@ multidict==6.1.0
# aiohttp
# yarl
mysqlclient==2.2.4
# via -r requirements/edx/base.txt
# via
# -r requirements/edx/base.txt
# forum
newrelic==9.13.0
# via
# -r requirements/edx/base.txt
Expand Down

0 comments on commit 740b127

Please sign in to comment.