From 740b1274f0f08a876bb43717c14a10e41707fcf8 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Fri, 27 Sep 2024 15:39:17 +0500 Subject: [PATCH] fix: resolve inconsistant python dependencies - 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 --- .../django_comment_client/tests/group_id.py | 91 ++++++++++++++++--- .../discussion/rest_api/tests/test_api.py | 1 - .../discussion/rest_api/tests/test_views.py | 1 + lms/djangoapps/discussion/tests/test_views.py | 4 +- .../comment_client/models.py | 4 +- requirements/edx/base.txt | 4 +- requirements/edx/development.txt | 1 + requirements/edx/doc.txt | 4 +- requirements/edx/testing.txt | 4 +- 9 files changed, 92 insertions(+), 22 deletions(-) diff --git a/lms/djangoapps/discussion/django_comment_client/tests/group_id.py b/lms/djangoapps/discussion/django_comment_client/tests/group_id.py index 1e67ca2e0676..0a5fbe491930 100644 --- a/lms/djangoapps/discussion/django_comment_client/tests/group_id.py +++ b/lms/djangoapps/discussion/django_comment_client/tests/group_id.py @@ -80,11 +80,24 @@ 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): @@ -92,11 +105,23 @@ def test_cohorted_topic_moderator_none_group_id(self, mock_is_forum_v2_enabled, 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): @@ -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): @@ -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) diff --git a/lms/djangoapps/discussion/rest_api/tests/test_api.py b/lms/djangoapps/discussion/rest_api/tests/test_api.py index da6ebfecbcdb..539503044afe 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_api.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_api.py @@ -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() diff --git a/lms/djangoapps/discussion/rest_api/tests/test_views.py b/lms/djangoapps/discussion/rest_api/tests/test_views.py index 337b24e4276f..e2efc648abd4 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_views.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_views.py @@ -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"}) diff --git a/lms/djangoapps/discussion/tests/test_views.py b/lms/djangoapps/discussion/tests/test_views.py index e0d3b869da3d..12cc180fb77b 100644 --- a/lms/djangoapps/discussion/tests/test_views.py +++ b/lms/djangoapps/discussion/tests/test_views.py @@ -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 @@ -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 diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/models.py b/openedx/core/djangoapps/django_comment_common/comment_client/models.py index 9395ca43f50b..9276b5707b3a 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/models.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/models.py @@ -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) @@ -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) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index ccb8266e4525..1cc86450ec4b 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -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 diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 26e2846e8c3b..bfafa033902a 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -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 diff --git a/requirements/edx/doc.txt b/requirements/edx/doc.txt index 80ccce710009..8ce3dd50fe82 100644 --- a/requirements/edx/doc.txt +++ b/requirements/edx/doc.txt @@ -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 diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 1ad14da129e4..8ecd2dcf6b0d 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -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