Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def send_ace_message(goal, session_id):
Returns true if sent, false if it absorbed an exception and did not send
"""
user = goal.user
if not user.has_usable_password():
log.info(f'Goal Reminder User is disabled {user.username} course {goal.course_key}')
return False
try:
course = CourseOverview.get_from_id(goal.course_key)
except CourseOverview.DoesNotExist:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Tests for the goal_reminder_email command"""

import uuid
from datetime import datetime

from botocore.exceptions import NoCredentialsError
Expand All @@ -18,7 +18,7 @@

from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from lms.djangoapps.course_goals.management.commands.goal_reminder_email import send_email_using_ses
from lms.djangoapps.course_goals.management.commands.goal_reminder_email import send_email_using_ses, send_ace_message
from lms.djangoapps.course_goals.models import CourseGoalReminderStatus
from lms.djangoapps.course_goals.tests.factories import (
CourseGoalFactory, CourseGoalReminderStatusFactory, UserActivityFactory,
Expand Down Expand Up @@ -220,6 +220,21 @@ def test_params_without_ses(self, mock_ace):
assert 'override_default_channel' not in msg.options
assert 'from_address' not in msg.options

@ddt.data(True, False)
@mock.patch('lms.djangoapps.course_goals.management.commands.goal_reminder_email.ace.send')
def test_goal_reminder_email_sent_to_disable_user(self, value, mock_ace):
"""
Test that the goal reminder email is not sent to disabled users.
"""
goal = self.make_valid_goal()
if value:
goal.user.set_password("12345678")
else:
goal.user.set_unusable_password()
goal.user.save()
send_ace_message(goal, str(uuid.uuid4()))
assert mock_ace.called is value


class TestGoalReminderEmailSES(TestCase):
"""
Expand Down
Loading