From 92bece4ae12b91738da8db1b3f1a1640c1cb55a1 Mon Sep 17 00:00:00 2001 From: Varsha Menon Date: Mon, 25 Nov 2024 10:15:57 -0500 Subject: [PATCH] fix: course mode list concatenation issue --- CHANGELOG.rst | 5 +++++ learning_assistant/__init__.py | 2 +- learning_assistant/views.py | 3 ++- tests/test_views.py | 12 ++++++------ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a9ac2da..cdcef76 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,9 +14,14 @@ Change Log Unreleased ********** +4.4.7 - 2024-11-25 +****************** +* Fixes the Course Chat View CourseMode concatenation issue + 4.4.6 - 2024-11-22 ****************** * Gates the chat history endpoint behind a waffle flag +* Add LearningAssistantAuditTrial model 4.4.5 - 2024-11-12 ****************** diff --git a/learning_assistant/__init__.py b/learning_assistant/__init__.py index b91c801..25bfe14 100644 --- a/learning_assistant/__init__.py +++ b/learning_assistant/__init__.py @@ -2,6 +2,6 @@ Plugin for a learning assistant backend, intended for use within edx-platform. """ -__version__ = '4.4.6' +__version__ = '4.4.7' default_app_config = 'learning_assistant.apps.LearningAssistantConfig' # pylint: disable=invalid-name diff --git a/learning_assistant/views.py b/learning_assistant/views.py index 764adac..8d9ed62 100644 --- a/learning_assistant/views.py +++ b/learning_assistant/views.py @@ -129,7 +129,8 @@ def post(self, request, course_run_id): if ( # Here we include CREDIT_MODE and NO_ID_PROFESSIONAL_MODE, as CourseMode.VERIFIED_MODES on its own # doesn't match what we count as "verified modes" in the frontend component. - enrollment_mode in CourseMode.VERIFIED_MODES + CourseMode.CREDIT_MODE + CourseMode.NO_ID_PROFESSIONAL_MODE + enrollment_mode in CourseMode.VERIFIED_MODES + CourseMode.CREDIT_MODES + + [CourseMode.NO_ID_PROFESSIONAL_MODE] or user_role_is_staff(user_role) ): return self._get_next_message(request, courserun_key, course_run_id) diff --git a/tests/test_views.py b/tests/test_views.py index 11b8ad8..edde3d6 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -140,8 +140,8 @@ def test_audit_trial_expired(self, mock_mode, mock_enrollment, mock_waffle.return_value = True mock_role.return_value = 'student' mock_mode.VERIFIED_MODES = ['verified'] - mock_mode.CREDIT_MODE = ['credit'] - mock_mode.NO_ID_PROFESSIONAL_MODE = ['no-id'] + mock_mode.CREDIT_MODES = ['credit'] + mock_mode.NO_ID_PROFESSIONAL_MODE = 'no-id' mock_mode.UPSELL_TO_VERIFIED_MODES = ['audit'] mock_mode.objects.get.return_value = MagicMock() mock_mode.expiration_datetime.return_value = datetime.now() - timedelta(days=1) @@ -165,8 +165,8 @@ def test_invalid_enrollment_mode(self, mock_mode, mock_enrollment, mock_role, mo mock_waffle.return_value = True mock_role.return_value = 'student' mock_mode.VERIFIED_MODES = ['verified'] - mock_mode.CREDIT_MODE = ['credit'] - mock_mode.NO_ID_PROFESSIONAL_MODE = ['no-id'] + mock_mode.CREDIT_MODES = ['credit'] + mock_mode.NO_ID_PROFESSIONAL_MODE = 'no-id' mock_mode.UPSELL_TO_VERIFIED_MODES = ['audit'] mock_mode.objects.get.return_value = MagicMock() mock_mode.expiration_datetime.return_value = datetime.now() - timedelta(days=1) @@ -206,8 +206,8 @@ def test_chat_response_default( mock_waffle.return_value = True mock_role.return_value = 'student' mock_mode.VERIFIED_MODES = ['verified'] - mock_mode.CREDIT_MODE = ['credit'] - mock_mode.NO_ID_PROFESSIONAL_MODE = ['no-id'] + mock_mode.CREDIT_MODES = ['credit'] + mock_mode.NO_ID_PROFESSIONAL_MODE = 'no-id' mock_mode.UPSELL_TO_VERIFIED_MODES = ['audit'] mock_enrollment.return_value = MagicMock(mode=enrollment_mode) mock_chat_response.return_value = (200, {'role': 'assistant', 'content': 'Something else'})